code
stringlengths
2.5k
150k
kind
stringclasses
1 value
kotlin Use a Kotlin Gradle project as a CocoaPods dependency Use a Kotlin Gradle project as a CocoaPods dependency ===================================================== You can use a Kotlin Multiplatform project with native targets as a CocoaPods dependency. You can include such a dependency in the Podfile of the Xcode project by its name and path to the project directory containing the generated Podspec. This dependency will be automatically built (and rebuilt) along with this project. Such an approach simplifies importing to Xcode by removing a need to write the corresponding Gradle tasks and Xcode build steps manually. You can add dependencies between a Kotlin Gradle project and an Xcode project with one or several targets. It's also possible to add dependencies between a Gradle project and multiple Xcode projects. However, in this case, you need to add a dependency by calling `pod install` manually for each Xcode project. In other cases, it's done automatically. Xcode project with one target ----------------------------- 1. Create an Xcode project with a `Podfile` if you haven't done so yet. 2. Add the path to your Xcode project `Podfile` with `podfile = project.file(..)` to `build.gradle.kts` (`build.gradle`) of your Kotlin project. This step helps synchronize your Xcode project with Gradle project dependencies by calling `pod install` for your `Podfile`. 3. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" pod("AFNetworking") { version = "~> 4.0.0" } podfile = project.file("../ios-app/Podfile") } } ``` 4. Add the name and path of the Gradle project you want to include in the Xcode project to `Podfile`. ``` use_frameworks! platform :ios, '13.5' target 'ios-app' do pod 'kotlin_library', :path => '../kotlin-library' end ``` 5. Re-import the project. Xcode project with several targets ---------------------------------- 1. Create an Xcode project with a `Podfile` if you haven't done so yet. 2. Add the path to your Xcode project `Podfile` with `podfile = project.file(..)` to `build.gradle.kts` (`build.gradle`) of your Kotlin project. This step helps synchronize your Xcode project with Gradle project dependencies by calling `pod install` for your `Podfile`. 3. Add dependencies to the Pod libraries you want to use in your project with `pod()`. 4. For each target, specify the minimum deployment target version for the Pod library. ``` kotlin { ios() tvos() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" tvos.deploymentTarget = "13.4" pod("AFNetworking") { version = "~> 4.0.0" } podfile = project.file("../severalTargetsXcodeProject/Podfile") // specify the path to the Podfile } } ``` 5. Add the name and path of the Gradle project you want to include in the Xcode project to the `Podfile`. ``` target 'iosApp' do use_frameworks! platform :ios, '13.5' # Pods for iosApp pod 'kotlin_library', :path => '../kotlin-library' end target 'TVosApp' do use_frameworks! platform :tvos, '13.4' # Pods for TVosApp pod 'kotlin_library', :path => '../kotlin-library' end ``` 6. Re-import the project. You can find a sample project [here](https://github.com/Kotlin/kmm-with-cocoapods-multitarget-xcode-sample). Last modified: 10 January 2023 [Add dependencies on a Pod library](native-cocoapods-libraries) [CocoaPods Gradle plugin DSL reference](native-cocoapods-dsl-reference) kotlin Basic types Basic types =========== In Kotlin, everything is an object in the sense that you can call member functions and properties on any variable. Some types can have a special internal representation – for example, numbers, characters and booleans can be represented as primitive values at runtime – but to the user they look like ordinary classes. This section describes the basic types used in Kotlin: * [Numbers](numbers) and their [unsigned counterparts](unsigned-integer-types) * [Booleans](booleans) * [Characters](characters) * [Strings](strings) * [Arrays](arrays) Last modified: 10 January 2023 [Coding conventions](coding-conventions) [Numbers](numbers) kotlin Get started with Kotlin Multiplatform Mobile Get started with Kotlin Multiplatform Mobile ============================================ Kotlin Multiplatform Mobile (KMM) is an SDK designed to simplify the development of cross-platform mobile applications. You can share common code between iOS and Android apps and write platform-specific code only where it's necessary. Common use cases for Kotlin Multiplatform Mobile include implementing a native UI or working with platform-specific APIs. Get to know Kotlin Multiplatform Mobile and create a mobile app that works on both Android and iOS by completing these steps: ![First step](https://kotlinlang.org/docs/images/icon-1.svg "First step") [Set up an environment for cross-platform mobile development](multiplatform-mobile-setup) ![Second step](https://kotlinlang.org/docs/images/icon-2.svg "Second step") [Create your first app that works both on Android and iOS with the IDE](multiplatform-mobile-create-first-app) ![Third step](https://kotlinlang.org/docs/images/icon-3.svg "Third step") [Add dependencies to your project](multiplatform-mobile-dependencies) ![Fourth step](https://kotlinlang.org/docs/images/icon-4.svg "Fourth step") [Upgrade your app](multiplatform-mobile-upgrade-app) ![Fifth step](https://kotlinlang.org/docs/images/icon-5.svg "Fifth step") [Wrap up your project](multiplatform-mobile-wrap-up) Next step --------- Start by setting up an environment for Kotlin Multiplatform Mobile development. **[Proceed to the next part](multiplatform-mobile-setup)** ### See also If you want to convert your existing Android project into a cross-platform app, follow these steps to make it work on iOS: ![First step](https://kotlinlang.org/docs/images/icon-1.svg "First step") [Set up an environment for cross-platform mobile development](multiplatform-mobile-setup) ![Second step](https://kotlinlang.org/docs/images/icon-2.svg "Second step") [Complete this tutorial to make your Android app cross-platform](multiplatform-mobile-integrate-in-existing-app) Join the community ------------------ * ![Slack](https://kotlinlang.org/docs/images/slack.svg "Slack") **Kotlin Slack**: get an [invitation](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up) and join the [#multiplatform](https://kotlinlang.slack.com/archives/C3PQML5NU) channel * ![Stack Overflow](https://kotlinlang.org/docs/images/stackoverflow.svg "Stack Overflow") **Stack Overflow**: subscribe to the ["kotlin-multiplatform" tag](https://stackoverflow.com/questions/tagged/kotlin-multiplatform) * ![YouTube](https://kotlinlang.org/docs/images/youtube.svg "YouTube") **Kotlin YouTube channel**: subscribe and watch videos about [Kotlin Multiplatform Mobile](https://www.youtube.com/playlist?list=PLlFc5cFwUnmy_oVc9YQzjasSNoAk4hk_C) Last modified: 10 January 2023 [Reflection](reflection) [Set up an environment](multiplatform-mobile-setup) kotlin Gradle Gradle ====== Gradle is a build system that helps to automate and manage your building process. It downloads required dependencies, packages your code, and prepares it for compilation. Learn about Gradle basics and specifics on the [Gradle website](https://docs.gradle.org/current/userguide/getting_started.html). You can set up your own project with [these instructions](gradle-configure-project) for different platforms or pass a small [step-by-step tutorial](get-started-with-jvm-gradle-project) that will show you how to create a simple backend "Hello World" application in Kotlin. In this chapter, you can also learn about: * [Compiler options and how to pass them](gradle-compiler-options). * [Incremental compilation, caches support, build reports, and the Kotlin daemon](gradle-compilation-and-caches). * [Support for Gradle plugin variants](gradle-plugin-variants). What's next? ------------ Learn about: * **Gradle Kotlin DSL**. The [Gradle Kotlin DSL](https://docs.gradle.org/current/userguide/kotlin_dsl.html) is a domain specific language that you can use to write build scripts quickly and efficiently. * **Annotation processing**. Kotlin supports annotation processing via the [Kotlin Symbol processing API](ksp-reference). * **Generating documentation**. To generate documentation for Kotlin projects, use [Dokka](https://github.com/Kotlin/dokka); please refer to the [Dokka README](https://github.com/Kotlin/dokka/blob/master/README.md#using-the-gradle-plugin) for configuration instructions. Dokka supports mixed-language projects and can generate output in multiple formats, including standard Javadoc. * **OSGi**. For OSGi support see the [Kotlin OSGi page](kotlin-osgi). Last modified: 10 January 2023 [Keywords and operators](keyword-reference) [Get started with Gradle and Kotlin/JVM](get-started-with-jvm-gradle-project) kotlin Shared mutable state and concurrency Shared mutable state and concurrency ==================================== Coroutines can be executed parallelly using a multi-threaded dispatcher like the [Dispatchers.Default](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html). It presents all the usual parallelism problems. The main problem being synchronization of access to **shared mutable state**. Some solutions to this problem in the land of coroutines are similar to the solutions in the multi-threaded world, but others are unique. The problem ----------- Let us launch a hundred coroutines all doing the same action a thousand times. We'll also measure their completion time for further comparisons: ``` suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } ``` We start with a very simple action that increments a shared mutable variable using multi-threaded [Dispatchers.Default](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html). ``` import kotlinx.coroutines.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart var counter = 0 fun main() = runBlocking { withContext(Dispatchers.Default) { massiveRun { counter++ } } println("Counter = $counter") } //sampleEnd ``` What does it print at the end? It is highly unlikely to ever print "Counter = 100000", because a hundred coroutines increment the `counter` concurrently from multiple threads without any synchronization. Volatiles are of no help ------------------------ There is a common misconception that making a variable `volatile` solves concurrency problem. Let us try it: ``` import kotlinx.coroutines.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart @Volatile // in Kotlin `volatile` is an annotation var counter = 0 fun main() = runBlocking { withContext(Dispatchers.Default) { massiveRun { counter++ } } println("Counter = $counter") } //sampleEnd ``` This code works slower, but we still don't get "Counter = 100000" at the end, because volatile variables guarantee linearizable (this is a technical term for "atomic") reads and writes to the corresponding variable, but do not provide atomicity of larger actions (increment in our case). Thread-safe data structures --------------------------- The general solution that works both for threads and for coroutines is to use a thread-safe (aka synchronized, linearizable, or atomic) data structure that provides all the necessary synchronization for the corresponding operations that needs to be performed on a shared state. In the case of a simple counter we can use `AtomicInteger` class which has atomic `incrementAndGet` operations: ``` import kotlinx.coroutines.* import java.util.concurrent.atomic.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart val counter = AtomicInteger() fun main() = runBlocking { withContext(Dispatchers.Default) { massiveRun { counter.incrementAndGet() } } println("Counter = $counter") } //sampleEnd ``` This is the fastest solution for this particular problem. It works for plain counters, collections, queues and other standard data structures and basic operations on them. However, it does not easily scale to complex state or to complex operations that do not have ready-to-use thread-safe implementations. Thread confinement fine-grained ------------------------------- *Thread confinement* is an approach to the problem of shared mutable state where all access to the particular shared state is confined to a single thread. It is typically used in UI applications, where all UI state is confined to the single event-dispatch/application thread. It is easy to apply with coroutines by using a single-threaded context. ``` import kotlinx.coroutines.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart val counterContext = newSingleThreadContext("CounterContext") var counter = 0 fun main() = runBlocking { withContext(Dispatchers.Default) { massiveRun { // confine each increment to a single-threaded context withContext(counterContext) { counter++ } } } println("Counter = $counter") } //sampleEnd ``` This code works very slowly, because it does *fine-grained* thread-confinement. Each individual increment switches from multi-threaded [Dispatchers.Default](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-default.html) context to the single-threaded context using [withContext(counterContext)](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/with-context.html) block. Thread confinement coarse-grained --------------------------------- In practice, thread confinement is performed in large chunks, e.g. big pieces of state-updating business logic are confined to the single thread. The following example does it like that, running each coroutine in the single-threaded context to start with. ``` import kotlinx.coroutines.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart val counterContext = newSingleThreadContext("CounterContext") var counter = 0 fun main() = runBlocking { // confine everything to a single-threaded context withContext(counterContext) { massiveRun { counter++ } } println("Counter = $counter") } //sampleEnd ``` This now works much faster and produces correct result. Mutual exclusion ---------------- Mutual exclusion solution to the problem is to protect all modifications of the shared state with a *critical section* that is never executed concurrently. In a blocking world you'd typically use `synchronized` or `ReentrantLock` for that. Coroutine's alternative is called [Mutex](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/index.html). It has [lock](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/lock.html) and [unlock](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/-mutex/unlock.html) functions to delimit a critical section. The key difference is that `Mutex.lock()` is a suspending function. It does not block a thread. There is also [withLock](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.sync/with-lock.html) extension function that conveniently represents `mutex.lock(); try { ... } finally { mutex.unlock() }` pattern: ``` import kotlinx.coroutines.* import kotlinx.coroutines.sync.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } //sampleStart val mutex = Mutex() var counter = 0 fun main() = runBlocking { withContext(Dispatchers.Default) { massiveRun { // protect each increment with lock mutex.withLock { counter++ } } } println("Counter = $counter") } //sampleEnd ``` The locking in this example is fine-grained, so it pays the price. However, it is a good choice for some situations where you absolutely must modify some shared state periodically, but there is no natural thread that this state is confined to. Actors ------ An [actor](https://en.wikipedia.org/wiki/Actor_model) is an entity made up of a combination of a coroutine, the state that is confined and encapsulated into this coroutine, and a channel to communicate with other coroutines. A simple actor can be written as a function, but an actor with a complex state is better suited for a class. There is an [actor](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/actor.html) coroutine builder that conveniently combines actor's mailbox channel into its scope to receive messages from and combines the send channel into the resulting job object, so that a single reference to the actor can be carried around as its handle. The first step of using an actor is to define a class of messages that an actor is going to process. Kotlin's [sealed classes](sealed-classes) are well suited for that purpose. We define `CounterMsg` sealed class with `IncCounter` message to increment a counter and `GetCounter` message to get its value. The latter needs to send a response. A [CompletableDeferred](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-completable-deferred/index.html) communication primitive, that represents a single value that will be known (communicated) in the future, is used here for that purpose. ``` // Message types for counterActor sealed class CounterMsg object IncCounter : CounterMsg() // one-way message to increment counter class GetCounter(val response: CompletableDeferred<Int>) : CounterMsg() // a request with reply ``` Then we define a function that launches an actor using an [actor](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/actor.html) coroutine builder: ``` // This function launches a new counter actor fun CoroutineScope.counterActor() = actor<CounterMsg> { var counter = 0 // actor state for (msg in channel) { // iterate over incoming messages when (msg) { is IncCounter -> counter++ is GetCounter -> msg.response.complete(counter) } } } ``` The main code is straightforward: ``` import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlin.system.* suspend fun massiveRun(action: suspend () -> Unit) { val n = 100 // number of coroutines to launch val k = 1000 // times an action is repeated by each coroutine val time = measureTimeMillis { coroutineScope { // scope for coroutines repeat(n) { launch { repeat(k) { action() } } } } } println("Completed ${n * k} actions in $time ms") } // Message types for counterActor sealed class CounterMsg object IncCounter : CounterMsg() // one-way message to increment counter class GetCounter(val response: CompletableDeferred<Int>) : CounterMsg() // a request with reply // This function launches a new counter actor fun CoroutineScope.counterActor() = actor<CounterMsg> { var counter = 0 // actor state for (msg in channel) { // iterate over incoming messages when (msg) { is IncCounter -> counter++ is GetCounter -> msg.response.complete(counter) } } } //sampleStart fun main() = runBlocking<Unit> { val counter = counterActor() // create the actor withContext(Dispatchers.Default) { massiveRun { counter.send(IncCounter) } } // send a message to get a counter value from an actor val response = CompletableDeferred<Int>() counter.send(GetCounter(response)) println("Counter = ${response.await()}") counter.close() // shutdown the actor } //sampleEnd ``` It does not matter (for correctness) what context the actor itself is executed in. An actor is a coroutine and a coroutine is executed sequentially, so confinement of the state to the specific coroutine works as a solution to the problem of shared mutable state. Indeed, actors may modify their own private state, but can only affect each other through messages (avoiding the need for any locks). Actor is more efficient than locking under load, because in this case it always has work to do and it does not have to switch to a different context at all. Last modified: 10 January 2023 [Coroutine exceptions handling](exception-handling) [Select expression (experimental)](select-expression)
programming_docs
kotlin Classes Classes ======= Classes in Kotlin are declared using the keyword `class`: ``` class Person { /*...*/ } ``` The class declaration consists of the class name, the class header (specifying its type parameters, the primary constructor, and some other things), and the class body surrounded by curly braces. Both the header and the body are optional; if the class has no body, the curly braces can be omitted. ``` class Empty ``` Constructors ------------ A class in Kotlin can have a *primary constructor* and one or more *secondary constructors*. The primary constructor is a part of the class header, and it goes after the class name and optional type parameters. ``` class Person constructor(firstName: String) { /*...*/ } ``` If the primary constructor does not have any annotations or visibility modifiers, the `constructor` keyword can be omitted: ``` class Person(firstName: String) { /*...*/ } ``` The primary constructor cannot contain any code. Initialization code can be placed in *initializer blocks* prefixed with the `init` keyword. During the initialization of an instance, the initializer blocks are executed in the same order as they appear in the class body, interleaved with the property initializers: ``` //sampleStart class InitOrderDemo(name: String) { val firstProperty = "First property: $name".also(::println) init { println("First initializer block that prints $name") } val secondProperty = "Second property: ${name.length}".also(::println) init { println("Second initializer block that prints ${name.length}") } } //sampleEnd fun main() { InitOrderDemo("hello") } ``` Primary constructor parameters can be used in the initializer blocks. They can also be used in property initializers declared in the class body: ``` class Customer(name: String) { val customerKey = name.uppercase() } ``` Kotlin has a concise syntax for declaring properties and initializing them from the primary constructor: ``` class Person(val firstName: String, val lastName: String, var age: Int) ``` Such declarations can also include default values of the class properties: ``` class Person(val firstName: String, val lastName: String, var isEmployed: Boolean = true) ``` You can use a [trailing comma](coding-conventions#trailing-commas) when you declare class properties: ``` class Person( val firstName: String, val lastName: String, var age: Int, // trailing comma ) { /*...*/ } ``` Much like regular properties, properties declared in the primary constructor can be mutable (`var`) or read-only (`val`). If the constructor has annotations or visibility modifiers, the `constructor` keyword is required and the modifiers go before it: ``` class Customer public @Inject constructor(name: String) { /*...*/ } ``` Learn more about [visibility modifiers](visibility-modifiers#constructors). ### Secondary constructors A class can also declare *secondary constructors*, which are prefixed with `constructor`: ``` class Person(val pets: MutableList<Pet> = mutableListOf()) class Pet { constructor(owner: Person) { owner.pets.add(this) // adds this pet to the list of its owner's pets } } ``` If the class has a primary constructor, each secondary constructor needs to delegate to the primary constructor, either directly or indirectly through another secondary constructor(s). Delegation to another constructor of the same class is done using the `this` keyword: ``` class Person(val name: String) { val children: MutableList<Person> = mutableListOf() constructor(name: String, parent: Person) : this(name) { parent.children.add(this) } } ``` Code in initializer blocks effectively becomes part of the primary constructor. Delegation to the primary constructor happens as the first statement of a secondary constructor, so the code in all initializer blocks and property initializers is executed before the body of the secondary constructor. Even if the class has no primary constructor, the delegation still happens implicitly, and the initializer blocks are still executed: ``` //sampleStart class Constructors { init { println("Init block") } constructor(i: Int) { println("Constructor $i") } } //sampleEnd fun main() { Constructors(1) } ``` If a non-abstract class does not declare any constructors (primary or secondary), it will have a generated primary constructor with no arguments. The visibility of the constructor will be public. If you don't want your class to have a public constructor, declare an empty primary constructor with non-default visibility: ``` class DontCreateMe private constructor() { /*...*/ } ``` Creating instances of classes ----------------------------- To create an instance of a class, call the constructor as if it were a regular function: ``` val invoice = Invoice() val customer = Customer("Joe Smith") ``` The process of creating instances of nested, inner, and anonymous inner classes is described in [Nested classes](nested-classes). Class members ------------- Classes can contain: * [Constructors and initializer blocks](#constructors) * [Functions](functions) * [Properties](properties) * [Nested and inner classes](nested-classes) * [Object declarations](object-declarations) Inheritance ----------- Classes can be derived from each other and form inheritance hierarchies. [Learn more about inheritance in Kotlin](inheritance). Abstract classes ---------------- A class may be declared `abstract`, along with some or all of its members. An abstract member does not have an implementation in its class. You don't need to annotate abstract classes or functions with `open`. ``` abstract class Polygon { abstract fun draw() } class Rectangle : Polygon() { override fun draw() { // draw the rectangle } } ``` You can override a non-abstract `open` member with an abstract one. ``` open class Polygon { open fun draw() { // some default polygon drawing method } } abstract class WildShape : Polygon() { // Classes that inherit WildShape need to provide their own // draw method instead of using the default on Polygon abstract override fun draw() } ``` Companion objects ----------------- If you need to write a function that can be called without having a class instance but that needs access to the internals of a class (such as a factory method), you can write it as a member of an [object declaration](object-declarations) inside that class. Even more specifically, if you declare a [companion object](object-declarations#companion-objects) inside your class, you can access its members using only the class name as a qualifier. Last modified: 10 January 2023 [Packages and imports](packages) [Inheritance](inheritance) kotlin Calling Java from Kotlin Calling Java from Kotlin ======================== Kotlin is designed with Java interoperability in mind. Existing Java code can be called from Kotlin in a natural way, and Kotlin code can be used from Java rather smoothly as well. In this section, we describe some details about calling Java code from Kotlin. Pretty much all Java code can be used without any issues: ``` import java.util.* fun demo(source: List<Int>) { val list = ArrayList<Int>() // 'for'-loops work for Java collections: for (item in source) { list.add(item) } // Operator conventions work as well: for (i in 0..source.size - 1) { list[i] = source[i] // get and set are called } } ``` Getters and setters ------------------- Methods that follow the Java conventions for getters and setters (no-argument methods with names starting with `get` and single-argument methods with names starting with `set`) are represented as properties in Kotlin. `Boolean` accessor methods (where the name of the getter starts with `is` and the name of the setter starts with `set`) are represented as properties which have the same name as the getter method. ``` import java.util.Calendar fun calendarDemo() { val calendar = Calendar.getInstance() if (calendar.firstDayOfWeek == Calendar.SUNDAY) { // call getFirstDayOfWeek() calendar.firstDayOfWeek = Calendar.MONDAY // call setFirstDayOfWeek() } if (!calendar.isLenient) { // call isLenient() calendar.isLenient = true // call setLenient() } } ``` Note that, if the Java class only has a setter, it isn't visible as a property in Kotlin because Kotlin doesn't support set-only properties. Methods returning void ---------------------- If a Java method returns `void`, it will return `Unit` when called from Kotlin. If by any chance someone uses that return value, it will be assigned at the call site by the Kotlin compiler since the value itself is known in advance (being `Unit`). Escaping for Java identifiers that are keywords in Kotlin --------------------------------------------------------- Some of the Kotlin keywords are valid identifiers in Java: `in`, `object`, `is`, and other. If a Java library uses a Kotlin keyword for a method, you can still call the method escaping it with the backtick (`) character: ``` foo.`is`(bar) ``` Null-safety and platform types ------------------------------ Any reference in Java may be `null`, which makes Kotlin's requirements of strict null-safety impractical for objects coming from Java. Types of Java declarations are treated in Kotlin in a specific manner and called *platform types*. Null-checks are relaxed for such types, so that safety guarantees for them are the same as in Java (see more [below](#mapped-types)). Consider the following examples: ``` val list = ArrayList<String>() // non-null (constructor result) list.add("Item") val size = list.size // non-null (primitive int) val item = list[0] // platform type inferred (ordinary Java object) ``` When you call methods on variables of platform types, Kotlin does not issue nullability errors at compile time, but the call may fail at runtime, because of a null-pointer exception or an assertion that Kotlin generates to prevent nulls from propagating: ``` item.substring(1) // allowed, throws an exception if item == null ``` Platform types are *non-denotable*, meaning that you can't write them down explicitly in the language. When a platform value is assigned to a Kotlin variable, you can rely on the type inference (the variable will have an inferred platform type then, as `item` has in the example above), or you can choose the type you expect (both nullable and non-null types are allowed): ``` val nullable: String? = item // allowed, always works val notNull: String = item // allowed, may fail at runtime ``` If you choose a non-null type, the compiler will emit an assertion upon assignment. This prevents Kotlin's non-null variables from holding nulls. Assertions are also emitted when you pass platform values to Kotlin functions expecting non-null values and in other cases. Overall, the compiler does its best to prevent nulls from propagating far through the program although sometimes this is impossible to eliminate entirely, because of generics. ### Notation for platform types As mentioned above, platform types can't be mentioned explicitly in the program, so there's no syntax for them in the language. Nevertheless, the compiler and IDE need to display them sometimes (for example, in error messages or parameter info), so there is a mnemonic notation for them: * `T!` means "`T` or `T?`", * `(Mutable)Collection<T>!` means "Java collection of `T` may be mutable or not, may be nullable or not", * `Array<(out) T>!` means "Java array of `T` (or a subtype of `T`), nullable or not" ### Nullability annotations Java types that have nullability annotations are represented not as platform types, but as actual nullable or non-null Kotlin types. The compiler supports several flavors of nullability annotations, including: * [JetBrains](https://www.jetbrains.com/idea/help/nullable-and-notnull-annotations.html) (`@Nullable` and `@NotNull` from the `org.jetbrains.annotations` package) * [JSpecify](https://jspecify.dev/) (`org.jspecify.nullness`) * Android (`com.android.annotations` and `android.support.annotations`) * JSR-305 (`javax.annotation`, more details below) * FindBugs (`edu.umd.cs.findbugs.annotations`) * Eclipse (`org.eclipse.jdt.annotation`) * Lombok (`lombok.NonNull`) * RxJava 3 (`io.reactivex.rxjava3.annotations`) You can specify whether the compiler reports a nullability mismatch based on the information from specific types of nullability annotations. Use the compiler option `-Xnullability-annotations=@<package-name>:<report-level>`. In the argument, specify the fully qualified nullability annotations package and one of these report levels: * `ignore` to ignore nullability mismatches * `warn` to report warnings * `strict` to report errors. See the full list of supported nullability annotations in the [Kotlin compiler source code](https://github.com/JetBrains/kotlin/blob/master/core/compiler.common.jvm/src/org/jetbrains/kotlin/load/java/JvmAnnotationNames.kt). ### Annotating type arguments and type parameters You can annotate the type arguments and type parameters of generic types to provide nullability information for them as well. #### Type arguments Consider these annotations on a Java declaration: ``` @NotNull Set<@NotNull String> toSet(@NotNull Collection<@NotNull String> elements) { ... } ``` They result in the following signature in Kotlin: ``` fun toSet(elements: (Mutable)Collection<String>) : (Mutable)Set<String> { ... } ``` When the `@NotNull` annotation is missing from a type argument, you get a platform type instead: ``` fun toSet(elements: (Mutable)Collection<String!>) : (Mutable)Set<String!> { ... } ``` Kotlin also takes into account nullability annotations on type arguments of base classes and interfaces. For example, there are two Java classes with the signatures provided below: ``` public class Base<T> {} ``` ``` public class Derived extends Base<@Nullable String> {} ``` In the Kotlin code, passing the instance of `Derived` where the `Base<String>` is assumed produces the warning. ``` fun takeBaseOfNotNullStrings(x: Base<String>) {} fun main() { takeBaseOfNotNullStrings(Derived()) // warning: nullability mismatch } ``` The upper bound of `Derived` is set to `Base<String?>`, which is different from `Base<String>`. Learn more about [Java generics in Kotlin](#java-generics-in-kotlin). #### Type parameters By default, the nullability of plain type parameters in both Kotlin and Java is undefined. In Java, you can specify it using nullability annotations. Let's annotate the type parameter of the `Base` class: ``` public class Base<@NotNull T> {} ``` When inheriting from `Base`, Kotlin expects a non-nullable type argument or type parameter. Thus, the following Kotlin code produces a warning: ``` class Derived<K> : Base<K> {} // warning: K has undefined nullability ``` You can fix it by specifying the upper bound `K : Any`. Kotlin also supports nullability annotations on the bounds of Java type parameters. Let's add bounds to `Base`: ``` public class BaseWithBound<T extends @NotNull Number> {} ``` Kotlin translates this just as follows: ``` class BaseWithBound<T : Number> {} ``` So passing nullable type as a type argument or type parameter produces a warning. Annotating type arguments and type parameters works with the Java 8 target or higher. The feature requires that the nullability annotations support the `TYPE_USE` target (`org.jetbrains.annotations` supports this in version 15 and above). Pass the `-Xtype-enhancement-improvements-strict-mode` compiler option to report errors in Kotlin code that uses nullability which deviates from the nullability annotations from Java. ### JSR-305 support The [`@Nonnull`](https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/Nonnull.html) annotation defined in [JSR-305](https://jcp.org/en/jsr/detail?id=305) is supported for denoting nullability of Java types. If the `@Nonnull(when = ...)` value is `When.ALWAYS`, the annotated type is treated as non-null; `When.MAYBE` and `When.NEVER` denote a nullable type; and `When.UNKNOWN` forces the type to be [platform one](#null-safety-and-platform-types). A library can be compiled against the JSR-305 annotations, but there's no need to make the annotations artifact (e.g. `jsr305.jar`) a compile dependency for the library consumers. The Kotlin compiler can read the JSR-305 annotations from a library without the annotations present on the classpath. [Custom nullability qualifiers (KEEP-79)](https://github.com/Kotlin/KEEP/blob/master/proposals/jsr-305-custom-nullability-qualifiers.md) are also supported (see below). #### Type qualifier nicknames If an annotation type is annotated with both [`@TypeQualifierNickname`](https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/meta/TypeQualifierNickname.html) and JSR-305 `@Nonnull` (or its another nickname, such as `@CheckForNull`), then the annotation type is itself used for retrieving precise nullability and has the same meaning as that nullability annotation: ``` @TypeQualifierNickname @Nonnull(when = When.ALWAYS) @Retention(RetentionPolicy.RUNTIME) public @interface MyNonnull { } @TypeQualifierNickname @CheckForNull // a nickname to another type qualifier nickname @Retention(RetentionPolicy.RUNTIME) public @interface MyNullable { } interface A { @MyNullable String foo(@MyNonnull String x); // in Kotlin (strict mode): `fun foo(x: String): String?` String bar(List<@MyNonnull String> x); // in Kotlin (strict mode): `fun bar(x: List<String>!): String!` } ``` #### Type qualifier defaults [`@TypeQualifierDefault`](https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/latest/javax/annotation/meta/TypeQualifierDefault.html) allows introducing annotations that, when being applied, define the default nullability within the scope of the annotated element. Such annotation type should itself be annotated with both `@Nonnull` (or its nickname) and `@TypeQualifierDefault(...)` with one or more `ElementType` values: * `ElementType.METHOD` for return types of methods * `ElementType.PARAMETER` for value parameters * `ElementType.FIELD` for fields * `ElementType.TYPE_USE` for any type including type arguments, upper bounds of type parameters and wildcard types The default nullability is used when a type itself is not annotated by a nullability annotation, and the default is determined by the innermost enclosing element annotated with a type qualifier default annotation with the `ElementType` matching the type usage. ``` @Nonnull @TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) public @interface NonNullApi { } @Nonnull(when = When.MAYBE) @TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER, ElementType.TYPE_USE}) public @interface NullableApi { } @NullableApi interface A { String foo(String x); // fun foo(x: String?): String? @NotNullApi // overriding default from the interface String bar(String x, @Nullable String y); // fun bar(x: String, y: String?): String // The List<String> type argument is seen as nullable because of `@NullableApi` // having the `TYPE_USE` element type: String baz(List<String> x); // fun baz(List<String?>?): String? // The type of `x` parameter remains platform because there's an explicit // UNKNOWN-marked nullability annotation: String qux(@Nonnull(when = When.UNKNOWN) String x); // fun baz(x: String!): String? } ``` Package-level default nullability is also supported: ``` // FILE: test/package-info.java @NonNullApi // declaring all types in package 'test' as non-nullable by default package test; ``` #### @UnderMigration annotation The `@UnderMigration` annotation (provided in a separate artifact `kotlin-annotations-jvm`) can be used by library maintainers to define the migration status for the nullability type qualifiers. The status value in `@UnderMigration(status = ...)` specifies how the compiler treats inappropriate usages of the annotated types in Kotlin (e.g. using a `@MyNullable`-annotated type value as non-null): * `MigrationStatus.STRICT` makes annotation work as any plain nullability annotation, i.e. report errors for the inappropriate usages and affect the types in the annotated declarations as they are seen in Kotlin * `MigrationStatus.WARN`: the inappropriate usages are reported as compilation warnings instead of errors, but the types in the annotated declarations remain platform * `MigrationStatus.IGNORE` makes the compiler ignore the nullability annotation completely A library maintainer can add `@UnderMigration` status to both type qualifier nicknames and type qualifier defaults: ``` @Nonnull(when = When.ALWAYS) @TypeQualifierDefault({ElementType.METHOD, ElementType.PARAMETER}) @UnderMigration(status = MigrationStatus.WARN) public @interface NonNullApi { } // The types in the class are non-null, but only warnings are reported // because `@NonNullApi` is annotated `@UnderMigration(status = MigrationStatus.WARN)` @NonNullApi public class Test {} ``` If a default type qualifier uses a type qualifier nickname and they are both `@UnderMigration`, the status from the default type qualifier is used. #### Compiler configuration The JSR-305 checks can be configured by adding the `-Xjsr305` compiler flag with the following options (and their combination): * `-Xjsr305={strict|warn|ignore}` to set up the behavior for non-`@UnderMigration` annotations. Custom nullability qualifiers, especially `@TypeQualifierDefault`, are already spread among many well-known libraries, and users may need to migrate smoothly when updating to the Kotlin version containing JSR-305 support. Since Kotlin 1.1.60, this flag only affects non-`@UnderMigration` annotations. * `-Xjsr305=under-migration:{strict|warn|ignore}` to override the behavior for the `@UnderMigration` annotations. Users may have different view on the migration status for the libraries: they may want to have errors while the official migration status is `WARN`, or vice versa, they may wish to postpone errors reporting for some until they complete their migration. * `-Xjsr305=@<fq.name>:{strict|warn|ignore}` to override the behavior for a single annotation, where `<fq.name>` is the fully qualified class name of the annotation. May appear several times for different annotations. This is useful for managing the migration state for a particular library. The `strict`, `warn` and `ignore` values have the same meaning as those of `MigrationStatus`, and only the `strict` mode affects the types in the annotated declarations as they are seen in Kotlin. For example, adding `-Xjsr305=ignore -Xjsr305=under-migration:ignore [email protected]:warn` to the compiler arguments makes the compiler generate warnings for inappropriate usages of types annotated by `@org.library.MyNullable` and ignore all other JSR-305 annotations. The default behavior is the same to `-Xjsr305=warn`. The `strict` value should be considered experimental (more checks may be added to it in the future). Mapped types ------------ Kotlin treats some Java types specifically. Such types are not loaded from Java "as is", but are *mapped* to corresponding Kotlin types. The mapping only matters at compile time, the runtime representation remains unchanged. Java's primitive types are mapped to corresponding Kotlin types (keeping [platform types](#null-safety-and-platform-types) in mind): | **Java type** | **Kotlin type** | | --- | --- | | `byte` | `kotlin.Byte` | | `short` | `kotlin.Short` | | `int` | `kotlin.Int` | | `long` | `kotlin.Long` | | `char` | `kotlin.Char` | | `float` | `kotlin.Float` | | `double` | `kotlin.Double` | | `boolean` | `kotlin.Boolean` | Some non-primitive built-in classes are also mapped: | **Java type** | **Kotlin type** | | --- | --- | | `java.lang.Object` | `kotlin.Any!` | | `java.lang.Cloneable` | `kotlin.Cloneable!` | | `java.lang.Comparable` | `kotlin.Comparable!` | | `java.lang.Enum` | `kotlin.Enum!` | | `java.lang.annotation.Annotation` | `kotlin.Annotation!` | | `java.lang.CharSequence` | `kotlin.CharSequence!` | | `java.lang.String` | `kotlin.String!` | | `java.lang.Number` | `kotlin.Number!` | | `java.lang.Throwable` | `kotlin.Throwable!` | Java's boxed primitive types are mapped to nullable Kotlin types: | **Java type** | **Kotlin type** | | --- | --- | | `java.lang.Byte` | `kotlin.Byte?` | | `java.lang.Short` | `kotlin.Short?` | | `java.lang.Integer` | `kotlin.Int?` | | `java.lang.Long` | `kotlin.Long?` | | `java.lang.Character` | `kotlin.Char?` | | `java.lang.Float` | `kotlin.Float?` | | `java.lang.Double` | `kotlin.Double?` | | `java.lang.Boolean` | `kotlin.Boolean?` | Note that a boxed primitive type used as a type parameter is mapped to a platform type: for example, `List<java.lang.Integer>` becomes a `List<Int!>` in Kotlin. Collection types may be read-only or mutable in Kotlin, so Java's collections are mapped as follows (all Kotlin types in this table reside in the package `kotlin.collections`): | **Java type** | **Kotlin read-only type** | **Kotlin mutable type** | **Loaded platform type** | | --- | --- | --- | --- | | `Iterator<T>` | `Iterator<T>` | `MutableIterator<T>` | `(Mutable)Iterator<T>!` | | `Iterable<T>` | `Iterable<T>` | `MutableIterable<T>` | `(Mutable)Iterable<T>!` | | `Collection<T>` | `Collection<T>` | `MutableCollection<T>` | `(Mutable)Collection<T>!` | | `Set<T>` | `Set<T>` | `MutableSet<T>` | `(Mutable)Set<T>!` | | `List<T>` | `List<T>` | `MutableList<T>` | `(Mutable)List<T>!` | | `ListIterator<T>` | `ListIterator<T>` | `MutableListIterator<T>` | `(Mutable)ListIterator<T>!` | | `Map<K, V>` | `Map<K, V>` | `MutableMap<K, V>` | `(Mutable)Map<K, V>!` | | `Map.Entry<K, V>` | `Map.Entry<K, V>` | `MutableMap.MutableEntry<K,V>` | `(Mutable)Map.(Mutable)Entry<K, V>!` | Java's arrays are mapped as mentioned [below](#java-arrays): | **Java type** | **Kotlin type** | | --- | --- | | `int[]` | `kotlin.IntArray!` | | `String[]` | `kotlin.Array<(out) String>!` | Java generics in Kotlin ----------------------- Kotlin's generics are a little different from Java's (see [Generics](generics)). When importing Java types to Kotlin, the following conversions are done: * Java's wildcards are converted into type projections: + `Foo<? extends Bar>` becomes `Foo<out Bar!>!` + `Foo<? super Bar>` becomes `Foo<in Bar!>!` * Java's raw types are converted into star projections: + `List` becomes `List<*>!` that is `List<out Any?>!` Like Java's, Kotlin's generics are not retained at runtime: objects do not carry information about actual type arguments passed to their constructors. For example, `ArrayList<Integer>()` is indistinguishable from `ArrayList<Character>()`. This makes it impossible to perform `is`-checks that take generics into account. Kotlin only allows `is`-checks for star-projected generic types: ``` if (a is List<Int>) // Error: cannot check if it is really a List of Ints // but if (a is List<*>) // OK: no guarantees about the contents of the list ``` Java arrays ----------- Arrays in Kotlin are invariant, unlike Java. This means that Kotlin won't let you assign an `Array<String>` to an `Array<Any>`, which prevents a possible runtime failure. Passing an array of a subclass as an array of superclass to a Kotlin method is also prohibited, but for Java methods this is allowed through [platform types](#null-safety-and-platform-types) of the form `Array<(out) String>!`. Arrays are used with primitive datatypes on the Java platform to avoid the cost of boxing/unboxing operations. As Kotlin hides those implementation details, a workaround is required to interface with Java code. There are specialized classes for every type of primitive array (`IntArray`, `DoubleArray`, `CharArray`, and so on) to handle this case. They are not related to the `Array` class and are compiled down to Java's primitive arrays for maximum performance. Suppose there is a Java method that accepts an int array of indices: ``` public class JavaArrayExample { public void removeIndices(int[] indices) { // code here... } } ``` To pass an array of primitive values, you can do the following in Kotlin: ``` val javaObj = JavaArrayExample() val array = intArrayOf(0, 1, 2, 3) javaObj.removeIndices(array) // passes int[] to method ``` When compiling to the JVM bytecode, the compiler optimizes access to arrays so that there's no overhead introduced: ``` val array = arrayOf(1, 2, 3, 4) array[1] = array[1] * 2 // no actual calls to get() and set() generated for (x in array) { // no iterator created print(x) } ``` Even when you navigate with an index, it does not introduce any overhead: ``` for (i in array.indices) { // no iterator created array[i] += 2 } ``` Finally, `in`-checks have no overhead either: ``` if (i in array.indices) { // same as (i >= 0 && i < array.size) print(array[i]) } ``` Java varargs ------------ Java classes sometimes use a method declaration for the indices with a variable number of arguments (varargs): ``` public class JavaArrayExample { public void removeIndicesVarArg(int... indices) { // code here... } } ``` In that case you need to use the spread operator `*` to pass the `IntArray`: ``` val javaObj = JavaArrayExample() val array = intArrayOf(0, 1, 2, 3) javaObj.removeIndicesVarArg(*array) ``` Operators --------- Since Java has no way of marking methods for which it makes sense to use the operator syntax, Kotlin allows using any Java methods with the right name and signature as operator overloads and other conventions (`invoke()` etc.) Calling Java methods using the infix call syntax is not allowed. Checked exceptions ------------------ In Kotlin, all [exceptions are unchecked](exceptions), meaning that the compiler does not force you to catch any of them. So, when you call a Java method that declares a checked exception, Kotlin does not force you to do anything: ``` fun render(list: List<*>, to: Appendable) { for (item in list) { to.append(item.toString()) // Java would require us to catch IOException here } } ``` Object methods -------------- When Java types are imported into Kotlin, all the references of the type `java.lang.Object` are turned into `Any`. Since `Any` is not platform-specific, it only declares `toString()`, `hashCode()` and `equals()` as its members, so to make other members of `java.lang.Object` available, Kotlin uses [extension functions](extensions). ### wait()/notify() Methods `wait()` and `notify()` are not available on references of type `Any`. Their usage is generally discouraged in favor of `java.util.concurrent`. If you really need to call these methods, you can cast to `java.lang.Object`: ``` (foo as java.lang.Object).wait() ``` ### getClass() To retrieve the Java class of an object, use the `java` extension property on a [class reference](reflection#class-references): ``` val fooClass = foo::class.java ``` The code above uses a [bound class reference](reflection#bound-class-references). You can also use the `javaClass` extension property: ``` val fooClass = foo.javaClass ``` ### clone() To override `clone()`, your class needs to extend `kotlin.Cloneable`: ``` class Example : Cloneable { override fun clone(): Any { ... } } ``` Don't forget about [Effective Java, 3rd Edition](https://www.oracle.com/technetwork/java/effectivejava-136174.html), Item 13: *Override clone judiciously*. ### finalize() To override `finalize()`, all you need to do is simply declare it, without using the `override` keyword: ``` class C { protected fun finalize() { // finalization logic } } ``` According to Java's rules, `finalize()` must not be `private`. Inheritance from Java classes ----------------------------- At most one Java class (and as many Java interfaces as you like) can be a supertype for a class in Kotlin. Accessing static members ------------------------ Static members of Java classes form "companion objects" for these classes. You can't pass such a "companion object" around as a value but can access the members explicitly, for example: ``` if (Character.isLetter(a)) { ... } ``` To access static members of a Java type that is [mapped](#mapped-types) to a Kotlin type, use the full qualified name of the Java type: `java.lang.Integer.bitCount(foo)`. Java reflection --------------- Java reflection works on Kotlin classes and vice versa. As mentioned above, you can use `instance::class.java`, `ClassName::class.java` or `instance.javaClass` to enter Java reflection through `java.lang.Class`. Do not use `ClassName.javaClass` for this purpose because it refers to `ClassName`'s companion object class, which is the same as `ClassName.Companion::class.java` and not `ClassName::class.java`. For each primitive type, there are two different Java classes, and Kotlin provides ways to get both. For example, `Int::class.java` will return the class instance representing the primitive type itself, corresponding to `Integer.TYPE` in Java. To get the class of the corresponding wrapper type, use `Int::class.javaObjectType`, which is equivalent of Java's `Integer.class`. Other supported cases include acquiring a Java getter/setter method or a backing field for a Kotlin property, a `KProperty` for a Java field, a Java method or constructor for a `KFunction` and vice versa. SAM conversions --------------- Kotlin supports SAM conversions for both Java and [Kotlin interfaces](fun-interfaces). This support for Java means that Kotlin function literals can be automatically converted into implementations of Java interfaces with a single non-default method, as long as the parameter types of the interface method match the parameter types of the Kotlin function. You can use this for creating instances of SAM interfaces: ``` val runnable = Runnable { println("This runs in a runnable") } ``` ...and in method calls: ``` val executor = ThreadPoolExecutor() // Java signature: void execute(Runnable command) executor.execute { println("This runs in a thread pool") } ``` If the Java class has multiple methods taking functional interfaces, you can choose the one you need to call by using an adapter function that converts a lambda to a specific SAM type. Those adapter functions are also generated by the compiler when needed: ``` executor.execute(Runnable { println("This runs in a thread pool") }) ``` Using JNI with Kotlin --------------------- To declare a function that is implemented in native (C or C++) code, you need to mark it with the `external` modifier: ``` external fun foo(x: Int): Double ``` The rest of the procedure works in exactly the same way as in Java. You can also mark property getters and setters as `external`: ``` var myProperty: String external get external set ``` Behind the scenes, this will create two functions `getMyProperty` and `setMyProperty`, both marked as `external`. Using Lombok-generated declarations in Kotlin --------------------------------------------- You can use Java's Lombok-generated declarations in Kotlin code. If you need to generate and use these declarations in the same mixed Java/Kotlin module, you can learn how to do this on the [Lombok compiler plugin's page](lombok). If you call such declarations from another module, then you don't need to use this plugin to compile that module. Last modified: 10 January 2023 [Comparison to Java](comparison-to-java) [Calling Kotlin from Java](java-to-kotlin-interop)
programming_docs
kotlin Operation arguments Operation arguments =================== In this tutorial, you'll learn how to configure operation arguments. Consider this straightforward `MultiMap` implementation below. It's based on the `ConcurrentHashMap`, internally storing a list of values: ``` import java.util.concurrent.* class MultiMap<K, V> { private val map = ConcurrentHashMap<K, List<V>>() // Maintains a list of values // associated with the specified key. fun add(key: K, value: V) { val list = map[key] if (list == null) { map[key] = listOf(value) } else { map[key] = list + value } } fun get(key: K): List<V> = map[key] ?: emptyList() } ``` Is this `MultiMap` implementation linearizable? If not, an incorrect interleaving is more likely to be detected when accessing a small range of keys, thus, increasing the possibility of processing the same key concurrently. For this, configure the generator for a `key: Int` parameter: 1. Declare the `@Param` annotation. 2. Specify the integer generator class: `@Param(gen = IntGen::class)`. Lincheck supports random parameter generators for almost all primitives and strings out of the box. 3. Define the range of values generated with the string configuration `@Param(conf = "1:2")`. 4. Specify the parameter configuration name (`@Param(name = "key")`) to share it for several operations. Below is the stress test for `MultiMap` that generates keys for `add(key, value)` and `get(key)` operations in the range of `[1..2]`: ``` import java.util.concurrent.* import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.paramgen.* import org.jetbrains.kotlinx.lincheck.strategy.stress.* import org.junit.* class MultiMap<K, V> { private val map = ConcurrentHashMap<K, List<V>>() // Maintains a list of values // associated with the specified key. fun add(key: K, value: V) { val list = map[key] if (list == null) { map[key] = listOf(value) } else { map[key] = list + value } } fun get(key: K): List<V> = map[key] ?: emptyList() } @Param(name = "key", gen = IntGen::class, conf = "1:2") class MultiMapTest { private val map = MultiMap<Int, Int>() @Operation fun add(@Param(name = "key") key: Int, value: Int) = map.add(key, value) @Operation fun get(@Param(name = "key") key: Int) = map.get(key) @Test fun stressTest() = StressOptions().check(this::class) @Test fun modelCheckingTest() = ModelCheckingOptions().check(this::class) } ``` 5. Run the `stressTest()` and see the following output: ``` = Invalid execution results = Parallel part: | add(1, 1): void | add(1, 4): void | Post part: [get(1): [4]] ``` 6. Finally, run `modelCheckingTest()`. It fails with the following output: ``` = Invalid execution results = Parallel part: | add(1, 6): void | add(1, -8): void | Post part: [get(1): [-8]] = The following interleaving leads to the error = Parallel part trace: | | add(1, -8) | | | add(1,-8) at MultiMapTest.add(MultiMapTest.kt:61) | | | get(1): null at MultiMap.add(MultiMapTest.kt:38) | | | switch | | add(1, 6): void | | | thread is finished | | | | put(1,[-8]): [6] at MultiMap.add(MultiMapTest.kt:40) | | | result: void | | | thread is finished | ``` Due to the small range of keys, Lincheck quickly reveals the race: when two values are being added concurrently by the same key, one of the values may be overwritten and lost. Next step --------- The current `MultiMap` implementation uses a complex `j.u.c.ConcurrentHashMap` data structure as a building block, the internal synchronization of which significantly increases the number of possible interleavings, so it may take a while to find a bug. If you consider the `j.u.c.ConcurrentHashMap` implementation correct, you can speed up testing and increase coverage with the [modular testing feature](modular-testing) available for the model checking strategy. See also -------- Learn how to test data structures that set access <constraints> on the execution. Last modified: 10 January 2023 [Stress testing and model checking](testing-strategies) [Modular testing](modular-testing) kotlin Using builders with builder type inference Using builders with builder type inference ========================================== Kotlin supports *builder type inference* (or builder inference), which can come in useful when you are working with generic builders. It helps the compiler infer the type arguments of a builder call based on the type information about other calls inside its lambda argument. Consider this example of [`buildMap()`](../api/latest/jvm/stdlib/kotlin.collections/build-map) usage: ``` fun addEntryToMap(baseMap: Map<String, Number>, additionalEntry: Pair<String, Int>?) { val myMap = buildMap { putAll(baseMap) if (additionalEntry != null) { put(additionalEntry.first, additionalEntry.second) } } } ``` There is not enough type information here to infer type arguments in a regular way, but builder inference can analyze the calls inside the lambda argument. Based on the type information about `putAll()` and `put()` calls, the compiler can automatically infer type arguments of the `buildMap()` call into `String` and `Number`. Builder inference allows to omit type arguments while using generic builders. Writing your own builders ------------------------- ### Requirements for enabling builder inference To let builder inference work for your own builder, make sure its declaration has a builder lambda parameter of a function type with a receiver. There are also two requirements for the receiver type: 1. It should use the type arguments that builder inference is supposed to infer. For example: ``` fun <V> buildList(builder: MutableList<V>.() -> Unit) { ... } ``` 2. It should provide public members or extensions that contain the corresponding type parameters in their signature. For example: ``` class ItemHolder<T> { private val items = mutableListOf<T>() fun addItem(x: T) { items.add(x) } fun getLastItem(): T? = items.lastOrNull() } fun <T> ItemHolder<T>.addAllItems(xs: List<T>) { xs.forEach { addItem(it) } } fun <T> itemHolderBuilder(builder: ItemHolder<T>.() -> Unit): ItemHolder<T> = ItemHolder<T>().apply(builder) fun test(s: String) { val itemHolder1 = itemHolderBuilder { // Type of itemHolder1 is ItemHolder<String> addItem(s) } val itemHolder2 = itemHolderBuilder { // Type of itemHolder2 is ItemHolder<String> addAllItems(listOf(s)) } val itemHolder3 = itemHolderBuilder { // Type of itemHolder3 is ItemHolder<String?> val lastItem: String? = getLastItem() // ... } } ``` ### Supported features Builder inference supports: * Inferring several type arguments ``` fun <K, V> myBuilder(builder: MutableMap<K, V>.() -> Unit): Map<K, V> { ... } ``` * Inferring type arguments of several builder lambdas within one call including interdependent ones ``` fun <K, V> myBuilder( listBuilder: MutableList<V>.() -> Unit, mapBuilder: MutableMap<K, V>.() -> Unit ): Pair<List<V>, Map<K, V>> = mutableListOf<V>().apply(listBuilder) to mutableMapOf<K, V>().apply(mapBuilder) fun main() { val result = myBuilder( { add(1) }, { put("key", 2) } ) // result has Pair<List<Int>, Map<String, Int>> type } ``` * Inferring type arguments whose type parameters are lambda's parameter or return types ``` fun <K, V> myBuilder1( mapBuilder: MutableMap<K, V>.() -> K ): Map<K, V> = mutableMapOf<K, V>().apply { mapBuilder() } fun <K, V> myBuilder2( mapBuilder: MutableMap<K, V>.(K) -> Unit ): Map<K, V> = mutableMapOf<K, V>().apply { mapBuilder(2 as K) } fun main() { // result1 has the Map<Long, String> type inferred val result1 = myBuilder1 { put(1L, "value") 2 } val result2 = myBuilder2 { put(1, "value 1") // You can use `it` as "postponed type variable" type // See the details in the section below put(it, "value 2") } } ``` How builder inference works --------------------------- ### Postponed type variables Builder inference works in terms of *postponed type variables*, which appear inside the builder lambda during builder inference analysis. A postponed type variable is a type argument's type, which is in the process of inferring. The compiler uses it to collect type information about the type argument. Consider the example with [`buildList()`](../api/latest/jvm/stdlib/kotlin.collections/build-list): ``` val result = buildList { val x = get(0) } ``` Here `x` has a type of postponed type variable: the `get()` call returns a value of type `E`, but `E` itself is not yet fixed. At this moment, a concrete type for `E` is unknown. When a value of a postponed type variable gets associated with a concrete type, builder inference collects this information to infer the resulting type of the corresponding type argument at the end of the builder inference analysis. For example: ``` val result = buildList { val x = get(0) val y: String = x } // result has the List<String> type inferred ``` After the postponed type variable gets assigned to a variable of the `String` type, builder inference gets the information that `x` is a subtype of `String`. This assignment is the last statement in the builder lambda, so the builder inference analysis ends with the result of inferring the type argument `E` into `String`. Note that you can always call `equals()`, `hashCode()`, and `toString()` functions with a postponed type variable as a receiver. ### Contributing to builder inference results Builder inference can collect different varieties of type information that contribute to the analysis result. It considers: * Calling methods on a lambda's receiver that use the type parameter's type ``` val result = buildList { // Type argument is inferred into String based on the passed "value" argument add("value") } // result has the List<String> type inferred ``` * Specifying the expected type for calls that return the type parameter's type ``` val result = buildList { // Type argument is inferred into Float based on the expected type val x: Float = get(0) } // result has the List<Float> type ``` ``` class Foo<T> { val items = mutableListOf<T>() } fun <K> myBuilder(builder: Foo<K>.() -> Unit): Foo<K> = Foo<K>().apply(builder) fun main() { val result = myBuilder { val x: List<CharSequence> = items // ... } // result has the Foo<CharSequence> type } ``` * Passing postponed type variables' types into methods that expect concrete types ``` fun takeMyLong(x: Long) { ... } fun String.isMoreThat3() = length > 3 fun takeListOfStrings(x: List<String>) { ... } fun main() { val result1 = buildList { val x = get(0) takeMyLong(x) } // result1 has the List<Long> type val result2 = buildList { val x = get(0) val isLong = x.isMoreThat3() // ... } // result2 has the List<String> type val result3 = buildList { takeListOfStrings(this) } // result3 has the List<String> type } ``` * Taking a callable reference to the lambda receiver's member ``` fun main() { val result = buildList { val x: KFunction1<Int, Float> = ::get } // result has the List<Float> type } ``` ``` fun takeFunction(x: KFunction1<Int, Float>) { ... } fun main() { val result = buildList { takeFunction(::get) } // result has the List<Float> type } ``` At the end of the analysis, builder inference considers all collected type information and tries to merge it into the resulting type. See the example. ``` val result = buildList { // Inferring postponed type variable E // Considering E is Number or a subtype of Number val n: Number? = getOrNull(0) // Considering E is Int or a supertype of Int add(1) // E gets inferred into Int } // result has the List<Int> type ``` The resulting type is the most specific type that corresponds to the type information collected during the analysis. If the given type information is contradictory and cannot be merged, the compiler reports an error. Note that the Kotlin compiler uses builder inference only if regular type inference cannot infer a type argument. This means you can contribute type information outside a builder lambda, and then builder inference analysis is not required. Consider the example: ``` fun someMap() = mutableMapOf<CharSequence, String>() fun <E> MutableMap<E, String>.f(x: MutableMap<E, String>) { ... } fun main() { val x: Map<in String, String> = buildMap { put("", "") f(someMap()) // Type mismatch (required String, found CharSequence) } } ``` Here a type mismatch appears because the expected type of the map is specified outside the builder lambda. The compiler analyzes all the statements inside with the fixed receiver type `Map<in String, String>`. Last modified: 10 January 2023 [Type-safe builders](type-safe-builders) [Null safety](null-safety) kotlin Idioms Idioms ====== A collection of random and frequently used idioms in Kotlin. If you have a favorite idiom, contribute it by sending a pull request. Create DTOs (POJOs/POCOs) ------------------------- ``` data class Customer(val name: String, val email: String) ``` provides a `Customer` class with the following functionality: * getters (and setters in case of `var`s) for all properties * `equals()` * `hashCode()` * `toString()` * `copy()` * `component1()`, `component2()`, ..., for all properties (see [Data classes](data-classes)) Default values for function parameters -------------------------------------- ``` fun foo(a: Int = 0, b: String = "") { ... } ``` Filter a list ------------- ``` val positives = list.filter { x -> x > 0 } ``` Or alternatively, even shorter: ``` val positives = list.filter { it > 0 } ``` Learn the difference between [Java and Kotlin filtering](java-to-kotlin-collections-guide#filter-elements). Check the presence of an element in a collection ------------------------------------------------ ``` if ("[email protected]" in emailsList) { ... } if ("[email protected]" !in emailsList) { ... } ``` String interpolation -------------------- ``` println("Name $name") ``` Learn the difference between [Java and Kotlin string concatenation](java-to-kotlin-idioms-strings#concatenate-strings). Instance checks --------------- ``` when (x) { is Foo -> ... is Bar -> ... else -> ... } ``` Read-only list -------------- ``` val list = listOf("a", "b", "c") ``` Read-only map ------------- ``` val map = mapOf("a" to 1, "b" to 2, "c" to 3) ``` Access a map entry ------------------ ``` println(map["key"]) map["key"] = value ``` Traverse a map or a list of pairs --------------------------------- ``` for ((k, v) in map) { println("$k -> $v") } ``` `k` and `v` can be any convenient names, such as `name` and `age`. Iterate over a range -------------------- ``` for (i in 1..100) { ... } // closed range: includes 100 for (i in 1 until 100) { ... } // half-open range: does not include 100 for (x in 2..10 step 2) { ... } for (x in 10 downTo 1) { ... } (1..10).forEach { ... } ``` Lazy property ------------- ``` val p: String by lazy { // the value is computed only on first access // compute the string } ``` Extension functions ------------------- ``` fun String.spaceToCamelCase() { ... } "Convert this to camelcase".spaceToCamelCase() ``` Create a singleton ------------------ ``` object Resource { val name = "Name" } ``` Instantiate an abstract class ----------------------------- ``` abstract class MyAbstractClass { abstract fun doSomething() abstract fun sleep() } fun main() { val myObject = object : MyAbstractClass() { override fun doSomething() { // ... } override fun sleep() { // ... } } myObject.doSomething() } ``` If-not-null shorthand --------------------- ``` val files = File("Test").listFiles() println(files?.size) // size is printed if files is not null ``` If-not-null-else shorthand -------------------------- ``` val files = File("Test").listFiles() println(files?.size ?: "empty") // if files is null, this prints "empty" // To calculate the fallback value in a code block, use `run` val filesSize = files?.size ?: run { return someSize } println(filesSize) ``` Execute a statement if null --------------------------- ``` val values = ... val email = values["email"] ?: throw IllegalStateException("Email is missing!") ``` Get first item of a possibly empty collection --------------------------------------------- ``` val emails = ... // might be empty val mainEmail = emails.firstOrNull() ?: "" ``` Learn the difference between [Java and Kotlin first item getting](java-to-kotlin-collections-guide#get-the-first-and-the-last-items-of-a-possibly-empty-collection). Execute if not null ------------------- ``` val value = ... value?.let { ... // execute this block if not null } ``` Map nullable value if not null ------------------------------ ``` val value = ... val mapped = value?.let { transformValue(it) } ?: defaultValue // defaultValue is returned if the value or the transform result is null. ``` Return on when statement ------------------------ ``` fun transform(color: String): Int { return when (color) { "Red" -> 0 "Green" -> 1 "Blue" -> 2 else -> throw IllegalArgumentException("Invalid color param value") } } ``` try-catch expression -------------------- ``` fun test() { val result = try { count() } catch (e: ArithmeticException) { throw IllegalStateException(e) } // Working with result } ``` if expression ------------- ``` val y = if (x == 1) { "one" } else if (x == 2) { "two" } else { "other" } ``` Builder-style usage of methods that return Unit ----------------------------------------------- ``` fun arrayOfMinusOnes(size: Int): IntArray { return IntArray(size).apply { fill(-1) } } ``` Single-expression functions --------------------------- ``` fun theAnswer() = 42 ``` This is equivalent to ``` fun theAnswer(): Int { return 42 } ``` This can be effectively combined with other idioms, leading to shorter code. For example, with the `when` expression: ``` fun transform(color: String): Int = when (color) { "Red" -> 0 "Green" -> 1 "Blue" -> 2 else -> throw IllegalArgumentException("Invalid color param value") } ``` Call multiple methods on an object instance (with) -------------------------------------------------- ``` class Turtle { fun penDown() fun penUp() fun turn(degrees: Double) fun forward(pixels: Double) } val myTurtle = Turtle() with(myTurtle) { //draw a 100 pix square penDown() for (i in 1..4) { forward(100.0) turn(90.0) } penUp() } ``` Configure properties of an object (apply) ----------------------------------------- ``` val myRectangle = Rectangle().apply { length = 4 breadth = 5 color = 0xFAFAFA } ``` This is useful for configuring properties that aren't present in the object constructor. Java 7's try-with-resources --------------------------- ``` val stream = Files.newInputStream(Paths.get("/some/file.txt")) stream.buffered().reader().use { reader -> println(reader.readText()) } ``` Generic function that requires the generic type information ----------------------------------------------------------- ``` // public final class Gson { // ... // public <T> T fromJson(JsonElement json, Class<T> classOfT) throws JsonSyntaxException { // ... inline fun <reified T: Any> Gson.fromJson(json: JsonElement): T = this.fromJson(json, T::class.java) ``` Nullable Boolean ---------------- ``` val b: Boolean? = ... if (b == true) { ... } else { // `b` is false or null } ``` Swap two variables ------------------ ``` var a = 1 var b = 2 a = b.also { b = a } ``` Mark code as incomplete (TODO) ------------------------------ Kotlin's standard library has a `TODO()` function that will always throw a `NotImplementedError`. Its return type is `Nothing` so it can be used regardless of expected type. There's also an overload that accepts a reason parameter: ``` fun calcTaxes(): BigDecimal = TODO("Waiting for feedback from accounting") ``` IntelliJ IDEA's kotlin plugin understands the semantics of `TODO()` and automatically adds a code pointer in the TODO tool window. What's next? ------------ * Solve [Advent of Code puzzles](advent-of-code) using the idiomatic Kotlin style. * Learn how to perform [typical tasks with strings in Java and Kotlin](java-to-kotlin-idioms-strings). * Learn how to perform [typical tasks with collections in Java and Kotlin](java-to-kotlin-collections-guide). * Learn how to [handle nullability in Java and Kotlin](java-to-kotlin-nullability-guide). Last modified: 10 January 2023 [Basic syntax](basic-syntax) [Coding conventions](coding-conventions)
programming_docs
kotlin What's new in Kotlin 1.4 What's new in Kotlin 1.4 ======================== *[Release date: 17 August 2020](releases#release-details)* In Kotlin 1.4.0, we ship a number of improvements in all of its components, with the [focus on quality and performance](https://blog.jetbrains.com/kotlin/2020/08/kotlin-1-4-released-with-a-focus-on-quality-and-performance/). Below you will find the list of the most important changes in Kotlin 1.4.0. Language features and improvements ---------------------------------- Kotlin 1.4.0 comes with a variety of different language features and improvements. They include: * [SAM conversions for Kotlin interfaces](#sam-conversions-for-kotlin-interfaces) * [Explicit API mode for library authors](#explicit-api-mode-for-library-authors) * [Mixing named and positional arguments](#mixing-named-and-positional-arguments) * [Trailing comma](#trailing-comma) * [Callable reference improvements](#callable-reference-improvements) * [break and continue inside when included in loops](#using-break-and-continue-inside-when-expressions-included-in-loops) ### SAM conversions for Kotlin interfaces Before Kotlin 1.4.0, you could apply SAM (Single Abstract Method) conversions only [when working with Java methods and Java interfaces from Kotlin](java-interop#sam-conversions). From now on, you can use SAM conversions for Kotlin interfaces as well. To do so, mark a Kotlin interface explicitly as functional with the `fun` modifier. SAM conversion applies if you pass a lambda as an argument when an interface with only one single abstract method is expected as a parameter. In this case, the compiler automatically converts the lambda to an instance of the class that implements the abstract member function. ``` fun interface IntPredicate { fun accept(i: Int): Boolean } val isEven = IntPredicate { it % 2 == 0 } fun main() { println("Is 7 even? - ${isEven.accept(7)}") } ``` [Learn more about Kotlin functional interfaces and SAM conversions](fun-interfaces). ### Explicit API mode for library authors Kotlin compiler offers *explicit API mode* for library authors. In this mode, the compiler performs additional checks that help make the library's API clearer and more consistent. It adds the following requirements for declarations exposed to the library's public API: * Visibility modifiers are required for declarations if the default visibility exposes them to the public API. This helps ensure that no declarations are exposed to the public API unintentionally. * Explicit type specifications are required for properties and functions that are exposed to the public API. This guarantees that API users are aware of the types of API members they use. Depending on your configuration, these explicit APIs can produce errors (*strict* mode) or warnings (*warning* mode). Certain kinds of declarations are excluded from such checks for the sake of readability and common sense: * primary constructors * properties of data classes * property getters and setters * `override` methods Explicit API mode analyzes only the production sources of a module. To compile your module in the explicit API mode, add the following lines to your Gradle build script: ``` kotlin { // for strict mode explicitApi() // or explicitApi = ExplicitApiMode.Strict // for warning mode explicitApiWarning() // or explicitApi = ExplicitApiMode.Warning } ``` ``` kotlin { // for strict mode explicitApi() // or explicitApi = 'strict' // for warning mode explicitApiWarning() // or explicitApi = 'warning' } ``` When using the command-line compiler, switch to explicit API mode by adding the `-Xexplicit-api` compiler option with the value `strict` or `warning`. ``` -Xexplicit-api={strict|warning} ``` [Find more details about the explicit API mode in the KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/explicit-api-mode.md). ### Mixing named and positional arguments In Kotlin 1.3, when you called a function with [named arguments](functions#named-arguments), you had to place all the arguments without names (positional arguments) before the first named argument. For example, you could call `f(1, y = 2)`, but you couldn't call `f(x = 1, 2)`. It was really annoying when all the arguments were in their correct positions but you wanted to specify a name for one argument in the middle. It was especially helpful for making absolutely clear which attribute a boolean or `null` value belongs to. In Kotlin 1.4, there is no such limitation – you can now specify a name for an argument in the middle of a set of positional arguments. Moreover, you can mix positional and named arguments any way you like, as long as they remain in the correct order. ``` fun reformat( str: String, uppercaseFirstLetter: Boolean = true, wordSeparator: Char = ' ' ) { // ... } //Function call with a named argument in the middle reformat("This is a String!", uppercaseFirstLetter = false , '-') ``` ### Trailing comma With Kotlin 1.4 you can now add a trailing comma in enumerations such as argument and parameter lists, `when` entries, and components of destructuring declarations. With a trailing comma, you can add new items and change their order without adding or removing commas. This is especially helpful if you use multi-line syntax for parameters or values. After adding a trailing comma, you can then easily swap lines with parameters or values. ``` fun reformat( str: String, uppercaseFirstLetter: Boolean = true, wordSeparator: Character = ' ', //trailing comma ) { // ... } ``` ``` val colors = listOf( "red", "green", "blue", //trailing comma ) ``` ### Callable reference improvements Kotlin 1.4 supports more cases for using callable references: * References to functions with default argument values * Function references in `Unit`-returning functions * References that adapt based on the number of arguments in a function * Suspend conversion on callable references #### References to functions with default argument values Now you can use callable references to functions with default argument values. If the callable reference to the function `foo` takes no arguments, the default value `0` is used. ``` fun foo(i: Int = 0): String = "$i!" fun apply(func: () -> String): String = func() fun main() { println(apply(::foo)) } ``` Previously, you had to write additional overloads for the function `apply` to use the default argument values. ``` // some new overload fun applyInt(func: (Int) -> String): String = func(0) ``` #### Function references in Unit-returning functions In Kotlin 1.4, you can use callable references to functions returning any type in `Unit`-returning functions. Before Kotlin 1.4, you could only use lambda arguments in this case. Now you can use both lambda arguments and callable references. ``` fun foo(f: () -> Unit) { } fun returnsInt(): Int = 42 fun main() { foo { returnsInt() } // this was the only way to do it before 1.4 foo(::returnsInt) // starting from 1.4, this also works } ``` #### References that adapt based on the number of arguments in a function Now you can adapt callable references to functions when passing a variable number of arguments (`vararg`) . You can pass any number of parameters of the same type at the end of the list of passed arguments. ``` fun foo(x: Int, vararg y: String) {} fun use0(f: (Int) -> Unit) {} fun use1(f: (Int, String) -> Unit) {} fun use2(f: (Int, String, String) -> Unit) {} fun test() { use0(::foo) use1(::foo) use2(::foo) } ``` #### Suspend conversion on callable references In addition to suspend conversion on lambdas, Kotlin now supports suspend conversion on callable references starting from version 1.4.0. ``` fun call() {} fun takeSuspend(f: suspend () -> Unit) {} fun test() { takeSuspend { call() } // OK before 1.4 takeSuspend(::call) // In Kotlin 1.4, it also works } ``` ### Using break and continue inside when expressions included in loops In Kotlin 1.3, you could not use unqualified `break` and `continue` inside `when` expressions included in loops. The reason was that these keywords were reserved for possible [fall-through behavior](https://en.wikipedia.org/wiki/Switch_statement#Fallthrough) in `when` expressions. That's why if you wanted to use `break` and `continue` inside `when` expressions in loops, you had to [label](returns#break-and-continue-labels) them, which became rather cumbersome. ``` fun test(xs: List<Int>) { LOOP@for (x in xs) { when (x) { 2 -> continue@LOOP 17 -> break@LOOP else -> println(x) } } } ``` In Kotlin 1.4, you can use `break` and `continue` without labels inside `when` expressions included in loops. They behave as expected by terminating the nearest enclosing loop or proceeding to its next step. ``` fun test(xs: List<Int>) { for (x in xs) { when (x) { 2 -> continue 17 -> break else -> println(x) } } } ``` The fall-through behavior inside `when` is subject to further design. New tools in the IDE -------------------- With Kotlin 1.4, you can use the new tools in IntelliJ IDEA to simplify Kotlin development: * [New flexible Project Wizard](#new-flexible-project-wizard) * [Coroutine Debugger](#coroutine-debugger) ### New flexible Project Wizard With the flexible new Kotlin Project Wizard, you have a place to easily create and configure different types of Kotlin projects, including multiplatform projects, which can be difficult to configure without a UI. ![Kotlin Project Wizard – Multiplatform project](https://kotlinlang.org/docs/images/multiplatform-project-1-wn.png "Kotlin Project Wizard – Multiplatform project")The new Kotlin Project Wizard is both simple and flexible: 1. *Select the project template*, depending on what you're trying to do. More templates will be added in the future. 2. *Select the build system* – Gradle (Kotlin or Groovy DSL), Maven, or IntelliJ IDEA. The Kotlin Project Wizard will only show the build systems supported on the selected project template. 3. *Preview the project structure* directly on the main screen. Then you can finish creating your project or, optionally, *configure the project* on the next screen: 4. *Add/remove modules and targets* supported for this project template. 5. *Configure module and target settings*, for example, the target JVM version, target template, and test framework. ![Kotlin Project Wizard - Configure targets](https://kotlinlang.org/docs/images/multiplatform-project-2-wn.png "Kotlin Project Wizard - Configure targets")In the future, we are going to make the Kotlin Project Wizard even more flexible by adding more configuration options and templates. You can try out the new Kotlin Project Wizard by working through these tutorials: * [Create a console application based on Kotlin/JVM](jvm-get-started) * [Create a Kotlin/JS application for React](js-get-started) * [Create a Kotlin/Native application](native-get-started) ### Coroutine Debugger Many people already use [coroutines](coroutines-guide) for asynchronous programming. But when it came to debugging, working with coroutines before Kotlin 1.4, could be a real pain. Since coroutines jumped between threads, it was difficult to understand what a specific coroutine was doing and check its context. In some cases, tracking steps over breakpoints simply didn't work. As a result, you had to rely on logging or mental effort to debug code that used coroutines. In Kotlin 1.4, debugging coroutines is now much more convenient with the new functionality shipped with the Kotlin plugin. The **Debug Tool Window** now contains a new **Coroutines** tab. In this tab, you can find information about both currently running and suspended coroutines. The coroutines are grouped by the dispatcher they are running on. ![Debugging coroutines](https://kotlinlang.org/docs/images/coroutine-debugger-wn.png "Debugging coroutines")Now you can: * Easily check the state of each coroutine. * See the values of local and captured variables for both running and suspended coroutines. * See a full coroutine creation stack, as well as a call stack inside the coroutine. The stack includes all frames with variable values, even those that would be lost during standard debugging. If you need a full report containing the state of each coroutine and its stack, right-click inside the **Coroutines** tab, and then click **Get Coroutines Dump**. Currently, the coroutines dump is rather simple, but we're going to make it more readable and helpful in future versions of Kotlin. ![Coroutines Dump](https://kotlinlang.org/docs/images/coroutines-dump-wn.png "Coroutines Dump")Learn more about debugging coroutines in [this blog post](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-debugging-coroutines/) and [IntelliJ IDEA documentation](https://www.jetbrains.com/help/idea/debug-kotlin-coroutines.html). New compiler ------------ The new Kotlin compiler is going to be really fast; it will unify all the supported platforms and provide an API for compiler extensions. It's a long-term project, and we've already completed several steps in Kotlin 1.4.0: * [New, more powerful type inference algorithm](#new-more-powerful-type-inference-algorithm) is enabled by default. * [New JVM and JS IR backends](#unified-backends-and-extensibility). They will become the default once we stabilize them. ### New more powerful type inference algorithm Kotlin 1.4 uses a new, more powerful type inference algorithm. This new algorithm was already available to try in Kotlin 1.3 by specifying a compiler option, and now it's used by default. You can find the full list of issues fixed in the new algorithm in [YouTrack](https://youtrack.jetbrains.com/issues/KT?q=Tag:%20fixed-in-new-inference%20). Here you can find some of the most noticeable improvements: * [More cases where type is inferred automatically](#more-cases-where-type-is-inferred-automatically) * [Smart casts for a lambda's last expression](#smart-casts-for-a-lambda-s-last-expression) * [Smart casts for callable references](#smart-casts-for-callable-references) * [Better inference for delegated properties](#better-inference-for-delegated-properties) * [SAM conversion for Java interfaces with different arguments](#sam-conversion-for-java-interfaces-with-different-arguments) * [Java SAM interfaces in Kotlin](#java-sam-interfaces-in-kotlin) #### More cases where type is inferred automatically The new inference algorithm infers types for many cases where the old algorithm required you to specify them explicitly. For instance, in the following example the type of the lambda parameter `it` is correctly inferred to `String?`: ``` //sampleStart val rulesMap: Map<String, (String?) -> Boolean> = mapOf( "weak" to { it != null }, "medium" to { !it.isNullOrBlank() }, "strong" to { it != null && "^[a-zA-Z0-9]+$".toRegex().matches(it) } ) //sampleEnd fun main() { println(rulesMap.getValue("weak")("abc!")) println(rulesMap.getValue("strong")("abc")) println(rulesMap.getValue("strong")("abc!")) } ``` In Kotlin 1.3, you needed to introduce an explicit lambda parameter or replace `to` with a `Pair` constructor with explicit generic arguments to make it work. #### Smart casts for a lambda's last expression In Kotlin 1.3, the last expression inside a lambda wasn't smart cast unless you specified the expected type. Thus, in the following example, Kotlin 1.3 infers `String?` as the type of the `result` variable: ``` val result = run { var str = currentValue() if (str == null) { str = "test" } str // the Kotlin compiler knows that str is not null here } // The type of 'result' is String? in Kotlin 1.3 and String in Kotlin 1.4 ``` In Kotlin 1.4, thanks to the new inference algorithm, the last expression inside a lambda gets smart cast, and this new, more precise type is used to infer the resulting lambda type. Thus, the type of the `result` variable becomes `String`. In Kotlin 1.3, you often needed to add explicit casts (either `!!` or type casts like `as String`) to make such cases work, and now these casts have become unnecessary. #### Smart casts for callable references In Kotlin 1.3, you couldn't access a member reference of a smart cast type. Now in Kotlin 1.4 you can: ``` import kotlin.reflect.KFunction sealed class Animal class Cat : Animal() { fun meow() { println("meow") } } class Dog : Animal() { fun woof() { println("woof") } } //sampleStart fun perform(animal: Animal) { val kFunction: KFunction<*> = when (animal) { is Cat -> animal::meow is Dog -> animal::woof } kFunction.call() } //sampleEnd fun main() { perform(Cat()) } ``` You can use different member references `animal::meow` and `animal::woof` after the animal variable has been smart cast to specific types `Cat` and `Dog`. After type checks, you can access member references corresponding to subtypes. #### Better inference for delegated properties The type of a delegated property wasn't taken into account while analyzing the delegate expression which follows the `by` keyword. For instance, the following code didn't compile before, but now the compiler correctly infers the types of the `old` and `new` parameters as `String?`: ``` import kotlin.properties.Delegates fun main() { var prop: String? by Delegates.observable(null) { p, old, new -> println("$old → $new") } prop = "abc" prop = "xyz" } ``` #### SAM conversion for Java interfaces with different arguments Kotlin has supported SAM conversions for Java interfaces from the beginning, but there was one case that wasn't supported, which was sometimes annoying when working with existing Java libraries. If you called a Java method that took two SAM interfaces as parameters, both arguments needed to be either lambdas or regular objects. You couldn't pass one argument as a lambda and another as an object. The new algorithm fixes this issue, and you can pass a lambda instead of a SAM interface in any case, which is the way you'd naturally expect it to work. ``` // FILE: A.java public class A { public static void foo(Runnable r1, Runnable r2) {} } ``` ``` // FILE: test.kt fun test(r1: Runnable) { A.foo(r1) {} // Works in Kotlin 1.4 } ``` #### Java SAM interfaces in Kotlin In Kotlin 1.4, you can use Java SAM interfaces in Kotlin and apply SAM conversions to them. ``` import java.lang.Runnable fun foo(r: Runnable) {} fun test() { foo { } // OK } ``` In Kotlin 1.3, you would have had to declare the function `foo` above in Java code to perform a SAM conversion. ### Unified backends and extensibility In Kotlin, we have three backends that generate executables: Kotlin/JVM, Kotlin/JS, and Kotlin/Native. Kotlin/JVM and Kotlin/JS don't share much code since they were developed independently of each other. Kotlin/Native is based on a new infrastructure built around an intermediate representation (IR) for Kotlin code. We are now migrating Kotlin/JVM and Kotlin/JS to the same IR. As a result, all three backends share a lot of logic and have a unified pipeline. This allows us to implement most features, optimizations, and bug fixes only once for all platforms. Both new IR-based back-ends are in [Alpha](components-stability). A common backend infrastructure also opens the door for multiplatform compiler extensions. You will be able to plug into the pipeline and add custom processing and transformations that will automatically work for all platforms. We encourage you to use our new [JVM IR](#new-jvm-ir-backend) and [JS IR](#new-js-ir-backend) backends, which are currently in Alpha, and share your feedback with us. Kotlin/JVM ---------- Kotlin 1.4.0 includes a number of JVM-specific improvements, such as: * [New JVM IR backend](#new-jvm-ir-backend) * [New modes for generating default methods in interfaces](#new-modes-for-generating-default-methods) * [Unified exception type for null checks](#unified-exception-type-for-null-checks) * [Type annotations in the JVM bytecode](#type-annotations-in-the-jvm-bytecode) ### New JVM IR backend Along with Kotlin/JS, we are migrating Kotlin/JVM to the [unified IR backend](#unified-backends-and-extensibility), which allows us to implement most features and bug fixes once for all platforms. You will also be able to benefit from this by creating multiplatform extensions that will work for all platforms. Kotlin 1.4.0 does not provide a public API for such extensions yet, but we are working closely with our partners, including [Jetpack Compose](https://developer.android.com/jetpack/compose), who are already building their compiler plugins using our new backend. We encourage you to try out the new Kotlin/JVM backend, which is currently in Alpha, and to file any issues and feature requests to our [issue tracker](https://youtrack.jetbrains.com/issues/KT). This will help us to unify the compiler pipelines and bring compiler extensions like Jetpack Compose to the Kotlin community more quickly. To enable the new JVM IR backend, specify an additional compiler option in your Gradle build script: ``` kotlinOptions.useIR = true ``` When using the command-line compiler, add the compiler option `-Xuse-ir`. ### New modes for generating default methods When compiling Kotlin code to targets JVM 1.8 and above, you could compile non-abstract methods of Kotlin interfaces into Java's `default` methods. For this purpose, there was a mechanism that includes the `@JvmDefault` annotation for marking such methods and the `-Xjvm-default` compiler option that enables processing of this annotation. In 1.4.0, we've added a new mode for generating default methods: `-Xjvm-default=all` compiles *all* non-abstract methods of Kotlin interfaces to `default` Java methods. For compatibility with the code that uses the interfaces compiled without `default`, we also added `all-compatibility` mode. For more information about default methods in the Java interop, see the [interoperability documentation](java-to-kotlin-interop#default-methods-in-interfaces) and [this blog post](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/). ### Unified exception type for null checks Starting from Kotlin 1.4.0, all runtime null checks will throw a `java.lang.NullPointerException` instead of `KotlinNullPointerException`, `IllegalStateException`, `IllegalArgumentException`, and `TypeCastException`. This applies to: the `!!` operator, parameter null checks in the method preamble, platform-typed expression null checks, and the `as` operator with a non-null type. This doesn't apply to `lateinit` null checks and explicit library function calls like `checkNotNull` or `requireNotNull`. This change increases the number of possible null check optimizations that can be performed either by the Kotlin compiler or by various kinds of bytecode processing tools, such as the Android [R8 optimizer](https://developer.android.com/studio/build/shrink-code). Note that from a developer's perspective, things won't change that much: the Kotlin code will throw exceptions with the same error messages as before. The type of exception changes, but the information passed stays the same. ### Type annotations in the JVM bytecode Kotlin can now generate type annotations in the JVM bytecode (target version 1.8+), so that they become available in Java reflection at runtime. To emit the type annotation in the bytecode, follow these steps: 1. Make sure that your declared annotation has a proper annotation target (Java's `ElementType.TYPE_USE` or Kotlin's `AnnotationTarget.TYPE`) and retention (`AnnotationRetention.RUNTIME`). 2. Compile the annotation class declaration to JVM bytecode target version 1.8+. You can specify it with `-jvm-target=1.8` compiler option. 3. Compile the code that uses the annotation to JVM bytecode target version 1.8+ (`-jvm-target=1.8`) and add the `-Xemit-jvm-type-annotations` compiler option. Note that the type annotations from the standard library aren't emitted in the bytecode for now because the standard library is compiled with the target version 1.6. So far, only the basic cases are supported: * Type annotations on method parameters, method return types and property types; * Invariant projections of type arguments, such as `Smth<@Ann Foo>`, `Array<@Ann Foo>`. In the following example, the `@Foo` annotation on the `String` type can be emitted to the bytecode and then used by the library code: ``` @Target(AnnotationTarget.TYPE) annotation class Foo class A { fun foo(): @Foo String = "OK" } ``` Kotlin/JS --------- On the JS platform, Kotlin 1.4.0 provides the following improvements: * [New Gradle DSL](#new-gradle-dsl) * [New JS IR backend](#new-js-ir-backend) ### New Gradle DSL The `kotlin.js` Gradle plugin comes with an adjusted Gradle DSL, which provides a number of new configuration options and is more closely aligned to the DSL used by the `kotlin-multiplatform` plugin. Some of the most impactful changes include: * Explicit toggles for the creation of executable files via `binaries.executable()`. Read more about the [executing Kotlin/JS and its environment here](js-project-setup#execution-environments). * Configuration of webpack's CSS and style loaders from within the Gradle configuration via `cssSupport`. Read more about [using CSS and style loaders here](js-project-setup#css). * Improved management for npm dependencies, with mandatory version numbers or [semver](https://docs.npmjs.com/misc/semver#versions) version ranges, as well as support for *development*, *peer*, and *optional* npm dependencies using `devNpm`, `optionalNpm` and `peerNpm`. [Read more about dependency management for npm packages directly from Gradle here](js-project-setup#npm-dependencies). * Stronger integrations for [Dukat](https://github.com/Kotlin/dukat), the generator for Kotlin external declarations. External declarations can now be generated at build time, or can be manually generated via a Gradle task. [Read more about how to use the integration here](js-external-declarations-with-dukat). ### New JS IR backend The [IR backend for Kotlin/JS](js-ir-compiler), which currently has [Alpha](components-stability) stability, provides some new functionality specific to the Kotlin/JS target which is focused around the generated code size through dead code elimination, and improved interoperation with JavaScript and TypeScript, among others. To enable the Kotlin/JS IR backend, set the key `kotlin.js.compiler=ir` in your `gradle.properties`, or pass the `IR` compiler type to the `js` function of your Gradle build script: ``` kotlin { js(IR) { // or: LEGACY, BOTH // . . . } binaries.executable() } ``` For more detailed information about how to configure the new backend, check out the [Kotlin/JS IR compiler documentation](js-ir-compiler). With the new [@JsExport](js-to-kotlin-interop#jsexport-annotation) annotation and the ability to **[generate TypeScript definitions](js-ir-compiler#preview-generation-of-typescript-declaration-files-d-ts) from Kotlin code**, the Kotlin/JS IR compiler backend improves JavaScript & TypeScript interoperability. This also makes it easier to integrate Kotlin/JS code with existing tooling, to create **hybrid applications** and leverage code-sharing functionality in multiplatform projects. [Learn more about the available features in the Kotlin/JS IR compiler backend](js-ir-compiler). Kotlin/Native ------------- In 1.4.0, Kotlin/Native got a significant number of new features and improvements, including: * [Support for suspending functions in Swift and Objective-C](#support-for-kotlin-s-suspending-functions-in-swift-and-objective-c) * [Objective-C generics support by default](#objective-c-generics-support-by-default) * [Exception handling in Objective-C/Swift interop](#exception-handling-in-objective-c-swift-interop) * [Generate release .dSYMs on Apple targets by default](#generate-release-dsyms-on-apple-targets-by-default) * [Performance improvements](#performance-improvements) * [Simplified management of CocoaPods dependencies](#simplified-management-of-cocoapods-dependencies) ### Support for Kotlin's suspending functions in Swift and Objective-C In 1.4.0, we add the basic support for suspending functions in Swift and Objective-C. Now, when you compile a Kotlin module into an Apple framework, suspending functions are available in it as functions with callbacks (`completionHandler` in the Swift/Objective-C terminology). When you have such functions in the generated framework's header, you can call them from your Swift or Objective-C code and even override them. For example, if you write this Kotlin function: ``` suspend fun queryData(id: Int): String = ... ``` ...then you can call it from Swift like so: ``` queryData(id: 17) { result, error in if let e = error { print("ERROR: \(e)") } else { print(result!) } } ``` [Learn more about using suspending functions in Swift and Objective-C](native-objc-interop). ### Objective-C generics support by default Previous versions of Kotlin provided experimental support for generics in Objective-C interop. Since 1.4.0, Kotlin/Native generates Apple frameworks with generics from Kotlin code by default. In some cases, this may break existing Objective-C or Swift code calling Kotlin frameworks. To have the framework header written without generics, add the `-Xno-objc-generics` compiler option. ``` kotlin { targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> { binaries.all { freeCompilerArgs += "-Xno-objc-generics" } } } ``` Please note that all specifics and limitations listed in the [documentation on interoperability with Objective-C](native-objc-interop#generics) are still valid. ### Exception handling in Objective-C/Swift interop In 1.4.0, we slightly change the Swift API generated from Kotlin with respect to the way exceptions are translated. There is a fundamental difference in error handling between Kotlin and Swift. All Kotlin exceptions are unchecked, while Swift has only checked errors. Thus, to make Swift code aware of expected exceptions, Kotlin functions should be marked with a `@Throws` annotation specifying a list of potential exception classes. When compiling to Swift or the Objective-C framework, functions that have or are inheriting `@Throws` annotation are represented as `NSError*`-producing methods in Objective-C and as `throws` methods in Swift. Previously, any exceptions other than `RuntimeException` and `Error` were propagated as `NSError`. Now this behavior changes: now `NSError` is thrown only for exceptions that are instances of classes specified as parameters of `@Throws` annotation (or their subclasses). Other Kotlin exceptions that reach Swift/Objective-C are considered unhandled and cause program termination. ### Generate release .dSYMs on Apple targets by default Starting with 1.4.0, the Kotlin/Native compiler produces [debug symbol files](https://developer.apple.com/documentation/xcode/building_your_app_to_include_debugging_information) (`.dSYM`s) for release binaries on Darwin platforms by default. This can be disabled with the `-Xadd-light-debug=disable` compiler option. On other platforms, this option is disabled by default. To toggle this option in Gradle, use: ``` kotlin { targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> { binaries.all { freeCompilerArgs += "-Xadd-light-debug={enable|disable}" } } } ``` [Learn more about crash report symbolication](native-ios-symbolication). ### Performance improvements Kotlin/Native has received a number of performance improvements that speed up both the development process and execution. Here are some examples: * To improve the speed of object allocation, we now offer the [mimalloc](https://github.com/microsoft/mimalloc) memory allocator as an alternative to the system allocator. mimalloc works up to two times faster on some benchmarks. Currently, the usage of mimalloc in Kotlin/Native is experimental; you can switch to it using the `-Xallocator=mimalloc` compiler option. * We've reworked how C interop libraries are built. With the new tooling, Kotlin/Native produces interop libraries up to 4 times as fast as before, and artifacts are 25% to 30% the size they used to be. * Overall runtime performance has improved because of optimizations in GC. This improvement will be especially apparent in projects with a large number of long-lived objects. `HashMap` and `HashSet` collections now work faster by escaping redundant boxing. * In 1.3.70 we introduced two new features for improving the performance of Kotlin/Native compilation: [caching project dependencies and running the compiler from the Gradle daemon](https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-3-70-released/#kotlin-native). Since that time, we've managed to fix numerous issues and improve the overall stability of these features. ### Simplified management of CocoaPods dependencies Previously, once you integrated your project with the dependency manager CocoaPods, you could build an iOS, macOS, watchOS, or tvOS part of your project only in Xcode, separate from other parts of your multiplatform project. These other parts could be built in IntelliJ IDEA. Moreover, every time you added a dependency on an Objective-C library stored in CocoaPods (Pod library), you had to switch from IntelliJ IDEA to Xcode, call `pod install`, and run the Xcode build there. Now you can manage Pod dependencies right in IntelliJ IDEA while enjoying the benefits it provides for working with code, such as code highlighting and completion. You can also build the whole Kotlin project with Gradle, without having to switch to Xcode. This means you only have to go to Xcode when you need to write Swift/Objective-C code or run your application on a simulator or device. Now you can also work with Pod libraries stored locally. Depending on your needs, you can add dependencies between: * A Kotlin project and Pod libraries stored remotely in the CocoaPods repository or stored locally on your machine. * A Kotlin Pod (Kotlin project used as a CocoaPods dependency) and an Xcode project with one or more targets. Complete the initial configuration, and when you add a new dependency to `cocoapods`, just re-import the project in IntelliJ IDEA. The new dependency will be added automatically. No additional steps are required. [Learn how to add dependencies](native-cocoapods-libraries). Kotlin Multiplatform -------------------- [Kotlin Multiplatform](multiplatform) reduces time spent writing and maintaining the same code for [different platforms](multiplatform-dsl-reference#targets) while retaining the flexibility and benefits of native programming. We continue investing our effort in multiplatform features and improvements: * [Sharing code in several targets with the hierarchical project structure](#sharing-code-in-several-targets-with-the-hierarchical-project-structure) * [Leveraging native libs in the hierarchical structure](#leveraging-native-libs-in-the-hierarchical-structure) * [Specifying kotlinx dependencies only once](#specifying-dependencies-only-once) ### Sharing code in several targets with the hierarchical project structure With the new hierarchical project structure support, you can share code among [several platforms](multiplatform-dsl-reference#targets) in a [multiplatform project](multiplatform-discover-project). Previously, any code added to a multiplatform project could be placed either in a platform-specific source set, which is limited to one target and can't be reused by any other platform, or in a common source set, like `commonMain` or `commonTest`, which is shared across all the platforms in the project. In the common source set, you could only call a platform-specific API by using an [`expect` declaration that needs platform-specific `actual` implementations](multiplatform-connect-to-apis). This made it easy to [share code on all platforms](multiplatform-share-on-platforms#share-code-on-all-platforms), but it was not so easy to [share between only some of the targets](multiplatform-share-on-platforms#share-code-on-similar-platforms), especially similar ones that could potentially reuse a lot of the common logic and third-party APIs. For example, in a typical multiplatform project targeting iOS, there are two iOS-related targets: one for iOS ARM64 devices, and the other for the x64 simulator. They have separate platform-specific source sets, but in practice, there is rarely a need for different code for the device and simulator, and their dependencies are much alike. So iOS-specific code could be shared between them. Apparently, in this setup, it would be desirable to have a *shared source set for two iOS targets*, with Kotlin/Native code that could still directly call any of the APIs that are common to both the iOS device and the simulator. ![Code shared for iOS targets](https://kotlinlang.org/docs/images/iosmain-hierarchy.png "Code shared for iOS targets")Now you can do this with the [hierarchical project structure support](multiplatform-share-on-platforms#share-code-on-similar-platforms), which infers and adapts the API and language features available in each source set based on which targets consume them. For common combinations of targets, you can create a hierarchical structure with [target shortcuts](multiplatform-share-on-platforms#use-target-shortcuts). For example, create two iOS targets and the shared source set shown above with the `ios()` shortcut: ``` kotlin { ios() // iOS device and simulator targets; iosMain and iosTest source sets } ``` For other combinations of targets, by connecting the source sets with the `dependsOn` relation. ![Hierarchical structure](https://kotlinlang.org/docs/images/hierarchical-structure.png "Hierarchical structure") ``` kotlin{ sourceSets { val desktopMain by creating { dependsOn(commonMain) } val linuxX64Main by getting { dependsOn(desktopMain) } val mingwX64Main by getting { dependsOn(desktopMain) } val macosX64Main by getting { dependsOn(desktopMain) } } } ``` ``` kotlin { sourceSets { desktopMain { dependsOn(commonMain) } linuxX64Main { dependsOn(desktopMain) } mingwX64Main { dependsOn(desktopMain) } macosX64Main { dependsOn(desktopMain) } } } ``` Thanks to the hierarchical project structure, libraries can also provide common APIs for a subset of targets. Learn more about [sharing code in libraries](multiplatform-share-on-platforms#share-code-in-libraries). ### Leveraging native libs in the hierarchical structure You can use platform-dependent libraries, such as `Foundation`, `UIKit`, and `POSIX`, in source sets shared among several native targets. This can help you share more native code without being limited by platform-specific dependencies. No additional steps are required – everything is done automatically. IntelliJ IDEA will help you detect common declarations that you can use in the shared code. [Learn more about usage of platform-dependent libraries](multiplatform-share-on-platforms#use-native-libraries-in-the-hierarchical-structure). ### Specifying dependencies only once From now on, instead of specifying dependencies on different variants of the same library in shared and platform-specific source sets where it is used, you should specify a dependency only once in the shared source set. ``` kotlin { sourceSets { val commonMain by getting { dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } } } } ``` ``` kotlin { sourceSets { commonMain { dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' } } } } ``` Don't use kotlinx library artifact names with suffixes specifying the platform, such as `-common`, `-native`, or similar, as they are NOT supported anymore. Instead, use the library base artifact name, which in the example above is `kotlinx-coroutines-core`. However, the change doesn't currently affect: * The `stdlib` library – starting from Kotlin 1.4.0, [the stdlib dependency is added automatically](#dependency-on-the-standard-library-added-by-default). * The `kotlin.test` library – you should still use `test-common` and `test-annotations-common`. These dependencies will be addressed later. If you need a dependency only for a specific platform, you can still use platform-specific variants of standard and kotlinx libraries with such suffixes as `-jvm` or`-js`, for example `kotlinx-coroutines-core-jvm`. [Learn more about configuring dependencies](gradle-configure-project#configure-dependencies). Gradle project improvements --------------------------- Besides Gradle project features and improvements that are specific to [Kotlin Multiplatform](#kotlin-multiplatform), [Kotlin/JVM](#kotlin-jvm), [Kotlin/Native](#kotlin-native), and [Kotlin/JS](#kotlin-js), there are several changes applicable to all Kotlin Gradle projects: * [Dependency on the standard library is now added by default](#dependency-on-the-standard-library-added-by-default) * [Kotlin projects require a recent version of Gradle](#minimum-gradle-version-for-kotlin-projects) * [Improved support for Kotlin Gradle DSL in the IDE](#improved-gradle-kts-support-in-the-ide) ### Dependency on the standard library added by default You no longer need to declare a dependency on the `stdlib` library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default. The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning. For platform-specific source sets, the corresponding platform-specific variant of the library is used, while a common standard library is added to the rest. The Kotlin Gradle plugin will select the appropriate JVM standard library depending on the `kotlinOptions.jvmTarget` [compiler option](gradle-compiler-options) of your Gradle build script. [Learn how to change the default behavior](gradle-configure-project#dependency-on-the-standard-library). ### Minimum Gradle version for Kotlin projects To enjoy the new features in your Kotlin projects, update Gradle to the [latest version](https://gradle.org/releases/). Multiplatform projects require Gradle 6.0 or later, while other Kotlin projects work with Gradle 5.4 or later. ### Improved \*.gradle.kts support in the IDE In 1.4.0, we continued improving the IDE support for Gradle Kotlin DSL scripts (`*.gradle.kts` files). Here is what the new version brings: * *Explicit loading of script configurations* for better performance. Previously, the changes you make to the build script were loaded automatically in the background. To improve the performance, we've disabled the automatic loading of build script configuration in 1.4.0. Now the IDE loads the changes only when you explicitly apply them. In Gradle versions earlier than 6.0, you need to manually load the script configuration by clicking **Load Configuration** in the editor. ![*.gradle.kts – Load Configuration](https://kotlinlang.org/docs/images/gradle-kts-load-config.png "*.gradle.kts – Load Configuration")In Gradle 6.0 and above, you can explicitly apply changes by clicking **Load Gradle Changes** or by reimporting the Gradle project. We've added one more action in IntelliJ IDEA 2020.1 with Gradle 6.0 and above – **Load Script Configurations**, which loads changes to the script configurations without updating the whole project. This takes much less time than reimporting the whole project. ![*.gradle.kts – Load Script Changes and Load Gradle Changes](https://kotlinlang.org/docs/images/gradle-kts.png "*.gradle.kts – Load Script Changes and Load Gradle Changes")You should also **Load Script Configurations** for newly created scripts or when you open a project with new Kotlin plugin for the first time. With Gradle 6.0 and above, you are now able to load all scripts at once as opposed to the previous implementation where they were loaded individually. Since each request requires the Gradle configuration phase to be executed, this could be resource-intensive for large Gradle projects. Currently, such loading is limited to `build.gradle.kts` and `settings.gradle.kts` files (please vote for the related [issue](https://github.com/gradle/gradle/issues/12640)). To enable highlighting for `init.gradle.kts` or applied [script plugins](https://docs.gradle.org/current/userguide/plugins.html#sec:script_plugins), use the old mechanism – adding them to standalone scripts. Configuration for that scripts will be loaded separately when you need it. You can also enable auto-reload for such scripts. ![*.gradle.kts – Add to standalone scripts](https://kotlinlang.org/docs/images/gradle-kts-standalone.png "*.gradle.kts – Add to standalone scripts") * *Better error reporting*. Previously you could only see errors from the Gradle Daemon in separate log files. Now the Gradle Daemon returns all the information about errors directly and shows it in the Build tool window. This saves you both time and effort. Standard library ---------------- Here is the list of the most significant changes to the Kotlin standard library in 1.4.0: * [Common exception processing API](#common-exception-processing-api) * [New functions for arrays and collections](#new-functions-for-arrays-and-collections) * [Functions for string manipulations](#functions-for-string-manipulations) * [Bit operations](#bit-operations) * [Delegated properties improvements](#delegated-properties-improvements) * [Converting from KType to Java Type](#converting-from-ktype-to-java-type) * [Proguard configurations for Kotlin reflection](#proguard-configurations-for-kotlin-reflection) * [Improving the existing API](#improving-the-existing-api) * [module-info descriptors for stdlib artifacts](#module-info-descriptors-for-stdlib-artifacts) * [Deprecations](#deprecations) * [Exclusion of the deprecated experimental coroutines](#exclusion-of-the-deprecated-experimental-coroutines) ### Common exception processing API The following API elements have been moved to the common library: * `Throwable.stackTraceToString()` extension function, which returns the detailed description of this throwable with its stack trace, and `Throwable.printStackTrace()`, which prints this description to the standard error output. * `Throwable.addSuppressed()` function, which lets you specify the exceptions that were suppressed in order to deliver the exception, and the `Throwable.suppressedExceptions` property, which returns a list of all the suppressed exceptions. * `@Throws` annotation, which lists exception types that will be checked when the function is compiled to a platform method (on JVM or native platforms). ### New functions for arrays and collections #### Collections In 1.4.0, the standard library includes a number of useful functions for working with **collections**: * `setOfNotNull()`, which makes a set consisting of all the non-null items among the provided arguments. ``` fun main() { //sampleStart val set = setOfNotNull(null, 1, 2, 0, null) println(set) //sampleEnd } ``` * `shuffled()` for sequences. ``` fun main() { //sampleStart val numbers = (0 until 50).asSequence() val result = numbers.map { it * 2 }.shuffled().take(5) println(result.toList()) //five random even numbers below 100 //sampleEnd } ``` * `*Indexed()` counterparts for `onEach()` and `flatMap()`. The operation that they apply to the collection elements has the element index as a parameter. ``` fun main() { //sampleStart listOf("a", "b", "c", "d").onEachIndexed { index, item -> println(index.toString() + ":" + item) } val list = listOf("hello", "kot", "lin", "world") val kotlin = list.flatMapIndexed { index, item -> if (index in 1..2) item.toList() else emptyList() } //sampleEnd println(kotlin) } ``` * `*OrNull()` counterparts `randomOrNull()`, `reduceOrNull()`, and `reduceIndexedOrNull()`. They return `null` on empty collections. ``` fun main() { //sampleStart val empty = emptyList<Int>() empty.reduceOrNull { a, b -> a + b } //empty.reduce { a, b -> a + b } // Exception: Empty collection can't be reduced. //sampleEnd } ``` * `runningFold()`, its synonym `scan()`, and `runningReduce()` apply the given operation to the collection elements sequentially, similarly to`fold()` and `reduce()`; the difference is that these new functions return the whole sequence of intermediate results. ``` fun main() { //sampleStart val numbers = mutableListOf(0, 1, 2, 3, 4, 5) val runningReduceSum = numbers.runningReduce { sum, item -> sum + item } val runningFoldSum = numbers.runningFold(10) { sum, item -> sum + item } //sampleEnd println(runningReduceSum.toString()) println(runningFoldSum.toString()) } ``` * `sumOf()` takes a selector function and returns a sum of its values for all elements of a collection. `sumOf()` can produce sums of the types `Int`, `Long`, `Double`, `UInt`, and `ULong`. On the JVM, `BigInteger` and `BigDecimal` are also available. ``` data class OrderItem(val name: String, val price: Double, val count: Int) fun main() { //sampleStart val order = listOf<OrderItem>( OrderItem("Cake", price = 10.0, count = 1), OrderItem("Coffee", price = 2.5, count = 3), OrderItem("Tea", price = 1.5, count = 2)) val total = order.sumOf { it.price * it.count } // Double val count = order.sumOf { it.count } // Int //sampleEnd println("You've ordered $count items that cost $total in total") } ``` * The `min()` and `max()` functions have been renamed to `minOrNull()` and `maxOrNull()` to comply with the naming convention used across the Kotlin collections API. An `*OrNull` suffix in the function name means that it returns `null` if the receiver collection is empty. The same applies to `minBy()`, `maxBy()`, `minWith()`, `maxWith()` – in 1.4, they have `*OrNull()` synonyms. * The new `minOf()` and `maxOf()` extension functions return the minimum and the maximum value of the given selector function on the collection items. ``` data class OrderItem(val name: String, val price: Double, val count: Int) fun main() { //sampleStart val order = listOf<OrderItem>( OrderItem("Cake", price = 10.0, count = 1), OrderItem("Coffee", price = 2.5, count = 3), OrderItem("Tea", price = 1.5, count = 2)) val highestPrice = order.maxOf { it.price } //sampleEnd println("The most expensive item in the order costs $highestPrice") } ``` There are also `minOfWith()` and `maxOfWith()`, which take a `Comparator` as an argument, and `*OrNull()` versions of all four functions that return `null` on empty collections. * New overloads for `flatMap` and `flatMapTo` let you use transformations with return types that don't match the receiver type, namely: + Transformations to `Sequence` on `Iterable`, `Array`, and `Map` + Transformations to `Iterable` on `Sequence` ``` fun main() { //sampleStart val list = listOf("kot", "lin") val lettersList = list.flatMap { it.asSequence() } val lettersSeq = list.asSequence().flatMap { it.toList() } //sampleEnd println(lettersList) println(lettersSeq.toList()) } ``` * `removeFirst()` and `removeLast()` shortcuts for removing elements from mutable lists, and `*orNull()` counterparts of these functions. #### Arrays To provide a consistent experience when working with different container types, we've also added new functions for **arrays**: * `shuffle()` puts the array elements in a random order. * `onEach()` performs the given action on each array element and returns the array itself. * `associateWith()` and `associateWithTo()` build maps with the array elements as keys. * `reverse()` for array subranges reverses the order of the elements in the subrange. * `sortDescending()` for array subranges sorts the elements in the subrange in descending order. * `sort()` and `sortWith()` for array subranges are now available in the common library. ``` fun main() { //sampleStart var language = "" val letters = arrayOf("k", "o", "t", "l", "i", "n") val fileExt = letters.onEach { language += it } .filterNot { it in "aeuio" }.take(2) .joinToString(prefix = ".", separator = "") println(language) // "kotlin" println(fileExt) // ".kt" letters.shuffle() letters.reverse(0, 3) letters.sortDescending(2, 5) println(letters.contentToString()) // [k, o, t, l, i, n] //sampleEnd } ``` Additionally, there are new functions for conversions between `CharArray`/`ByteArray` and `String`: * `ByteArray.decodeToString()` and `String.encodeToByteArray()` * `CharArray.concatToString()` and `String.toCharArray()` ``` fun main() { //sampleStart val str = "kotlin" val array = str.toCharArray() println(array.concatToString()) //sampleEnd } ``` #### ArrayDeque We've also added the `ArrayDeque` class – an implementation of a double-ended queue. A double-ended queue lets you add or remove elements both at the beginning or end of the queue in an amortized constant time. You can use a double-ended queue by default when you need a queue or a stack in your code. ``` fun main() { val deque = ArrayDeque(listOf(1, 2, 3)) deque.addFirst(0) deque.addLast(4) println(deque) // [0, 1, 2, 3, 4] println(deque.first()) // 0 println(deque.last()) // 4 deque.removeFirst() deque.removeLast() println(deque) // [1, 2, 3] } ``` The `ArrayDeque` implementation uses a resizable array underneath: it stores the contents in a circular buffer, an `Array`, and resizes this `Array` only when it becomes full. ### Functions for string manipulations The standard library in 1.4.0 includes a number of improvements in the API for string manipulation: * `StringBuilder` has useful new extension functions: `set()`, `setRange()`, `deleteAt()`, `deleteRange()`, `appendRange()`, and others. ``` fun main() { //sampleStart val sb = StringBuilder("Bye Kotlin 1.3.72") sb.deleteRange(0, 3) sb.insertRange(0, "Hello", 0 ,5) sb.set(15, '4') sb.setRange(17, 19, "0") print(sb.toString()) //sampleEnd } ``` * Some existing functions of `StringBuilder` are available in the common library. Among them are `append()`, `insert()`, `substring()`, `setLength()`, and more. * New functions `Appendable.appendLine()` and `StringBuilder.appendLine()` have been added to the common library. They replace the JVM-only `appendln()` functions of these classes. ``` fun main() { //sampleStart println(buildString { appendLine("Hello,") appendLine("world") }) //sampleEnd } ``` ### Bit operations New functions for bit manipulations: * `countOneBits()` * `countLeadingZeroBits()` * `countTrailingZeroBits()` * `takeHighestOneBit()` * `takeLowestOneBit()` * `rotateLeft()` and `rotateRight()` (experimental) ``` fun main() { //sampleStart val number = "1010000".toInt(radix = 2) println(number.countOneBits()) println(number.countTrailingZeroBits()) println(number.takeHighestOneBit().toString(2)) //sampleEnd } ``` ### Delegated properties improvements In 1.4.0, we have added new features to improve your experience with delegated properties in Kotlin: * Now a property can be delegated to another property. * A new interface `PropertyDelegateProvider` helps create delegate providers in a single declaration. * `ReadWriteProperty` now extends `ReadOnlyProperty` so you can use both of them for read-only properties. Aside from the new API, we've made some optimizations that reduce the resulting bytecode size. These optimizations are described in [this blog post](https://blog.jetbrains.com/kotlin/2019/12/what-to-expect-in-kotlin-1-4-and-beyond/#delegated-properties). [Learn more about delegated properties](delegated-properties). ### Converting from KType to Java Type A new extension property `KType.javaType` (currently experimental) in the stdlib helps you obtain a `java.lang.reflect.Type` from a Kotlin type without using the whole `kotlin-reflect` dependency. ``` import kotlin.reflect.javaType import kotlin.reflect.typeOf @OptIn(ExperimentalStdlibApi::class) inline fun <reified T> accessReifiedTypeArg() { val kType = typeOf<T>() println("Kotlin type: $kType") println("Java type: ${kType.javaType}") } @OptIn(ExperimentalStdlibApi::class) fun main() { accessReifiedTypeArg<String>() // Kotlin type: kotlin.String // Java type: class java.lang.String accessReifiedTypeArg<List<String>>() // Kotlin type: kotlin.collections.List<kotlin.String> // Java type: java.util.List<java.lang.String> } ``` ### Proguard configurations for Kotlin reflection Starting from 1.4.0, we have embedded Proguard/R8 configurations for Kotlin Reflection in `kotlin-reflect.jar`. With this in place, most Android projects using R8 or Proguard should work with kotlin-reflect without needing any additional configuration. You no longer need to copy-paste the Proguard rules for kotlin-reflect internals. But note that you still need to explicitly list all the APIs you're going to reflect on. ### Improving the existing API * Several functions now work on null receivers, for example: + `toBoolean()` on strings + `contentEquals()`, `contentHashcode()`, `contentToString()` on arrays * `NaN`, `NEGATIVE_INFINITY`, and `POSITIVE_INFINITY` in `Double` and `Float` are now defined as `const`, so you can use them as annotation arguments. * New constants `SIZE_BITS` and `SIZE_BYTES` in `Double` and `Float` contain the number of bits and bytes used to represent an instance of the type in binary form. * The `maxOf()` and `minOf()` top-level functions can accept a variable number of arguments (`vararg`). ### module-info descriptors for stdlib artifacts Kotlin 1.4.0 adds `module-info.java` module information to default standard library artifacts. This lets you use them with [jlink tool](https://docs.oracle.com/en/java/javase/11/tools/jlink.html), which generates custom Java runtime images containing only the platform modules that are required for your app. You could already use jlink with Kotlin standard library artifacts, but you had to use separate artifacts to do so – the ones with the "modular" classifier – and the whole setup wasn't straightforward. In Android, make sure you use the Android Gradle plugin version 3.2 or higher, which can correctly process jar files with module-info. ### Deprecations #### toShort() and toByte() of Double and Float We've deprecated the functions `toShort()` and `toByte()` on `Double` and `Float` because they could lead to unexpected results because of the narrow value range and smaller variable size. To convert floating-point numbers to `Byte` or `Short`, use the two-step conversion: first, convert them to `Int`, and then convert them again to the target type. #### contains(), indexOf(), and lastIndexOf() on floating-point arrays We've deprecated the `contains()`, `indexOf()`, and `lastIndexOf()` extension functions of `FloatArray` and `DoubleArray` because they use the [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754) standard equality, which contradicts the total order equality in some corner cases. See [this issue](https://youtrack.jetbrains.com/issue/KT-28753) for details. #### min() and max() collection functions We've deprecated the `min()` and `max()` collection functions in favor of `minOrNull()` and `maxOrNull()`, which more properly reflect their behavior – returning `null` on empty collections. See [this issue](https://youtrack.jetbrains.com/issue/KT-38854) for details. ### Exclusion of the deprecated experimental coroutines The `kotlin.coroutines.experimental` API was deprecated in favor of kotlin.coroutines in 1.3.0. In 1.4.0, we're completing the deprecation cycle for `kotlin.coroutines.experimental` by removing it from the standard library. For those who still use it on the JVM, we've provided a compatibility artifact `kotlin-coroutines-experimental-compat.jar` with all the experimental coroutines APIs. We've published it to Maven, and we include it in the Kotlin distribution alongside the standard library. Stable JSON serialization ------------------------- With Kotlin 1.4.0, we are shipping the first stable version of [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) - 1.0.0-RC. Now we are pleased to declare the JSON serialization API in `kotlinx-serialization-core` (previously known as `kotlinx-serialization-runtime`) stable. Libraries for other serialization formats remain experimental, along with some advanced parts of the core library. We have significantly reworked the API for JSON serialization to make it more consistent and easier to use. From now on, we'll continue developing the JSON serialization API in a backward-compatible manner. However, if you have used previous versions of it, you'll need to rewrite some of your code when migrating to 1.0.0-RC. To help you with this, we also offer the **[Kotlin Serialization Guide](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serialization-guide.md)** – the complete set of documentation for `kotlinx.serialization`. It will guide you through the process of using the most important features and it can help you address any issues that you might face. Scripting and REPL ------------------ In 1.4.0, scripting in Kotlin benefits from a number of functional and performance improvements along with other updates. Here are some of the key changes: * [New dependencies resolution API](#new-dependencies-resolution-api) * [New REPL API](#new-repl-api) * [Compiled scripts cache](#compiled-scripts-cache) * [Artifacts renaming](#artifacts-renaming) To help you become more familiar with scripting in Kotlin, we've prepared a [project with examples](https://github.com/Kotlin/kotlin-script-examples). It contains examples of the standard scripts (`*.main.kts`) and examples of uses of the Kotlin Scripting API and custom script definitions. Please give it a try and share your feedback using our [issue tracker](https://youtrack.jetbrains.com/issues/KT). ### New dependencies resolution API In 1.4.0, we've introduced a new API for resolving external dependencies (such as Maven artifacts), along with implementations for it. This API is published in the new artifacts `kotlin-scripting-dependencies` and `kotlin-scripting-dependencies-maven`. The previous dependency resolution functionality in `kotlin-script-util` library is now deprecated. ### New REPL API The new experimental REPL API is now a part of the Kotlin Scripting API. There are also several implementations of it in the published artifacts, and some have advanced functionality, such as code completion. We use this API in the [Kotlin Jupyter kernel](https://blog.jetbrains.com/kotlin/2020/05/kotlin-kernel-for-jupyter-notebook-v0-8/) and now you can try it in your own custom shells and REPLs. ### Compiled scripts cache The Kotlin Scripting API now provides the ability to implement a compiled scripts cache, significantly speeding up subsequent executions of unchanged scripts. Our default advanced script implementation `kotlin-main-kts` already has its own cache. ### Artifacts renaming In order to avoid confusion about artifact names, we've renamed `kotlin-scripting-jsr223-embeddable` and `kotlin-scripting-jvm-host-embeddable` to just `kotlin-scripting-jsr223` and `kotlin-scripting-jvm-host`. These artifacts depend on the `kotlin-compiler-embeddable` artifact, which shades the bundled third-party libraries to avoid usage conflicts. With this renaming, we're making the usage of `kotlin-compiler-embeddable` (which is safer in general) the default for scripting artifacts. If, for some reason, you need artifacts that depend on the unshaded `kotlin-compiler`, use the artifact versions with the `-unshaded` suffix, such as `kotlin-scripting-jsr223-unshaded`. Note that this renaming affects only the scripting artifacts that are supposed to be used directly; names of other artifacts remain unchanged. Migrating to Kotlin 1.4.0 ------------------------- The Kotlin plugin's migration tools help you migrate your projects from earlier versions of Kotlin to 1.4.0. Just change the Kotlin version to `1.4.0` and re-import your Gradle or Maven project. The IDE will then ask you about migration. If you agree, it will run migration code inspections that will check your code and suggest corrections for anything that doesn't work or that is not recommended in 1.4.0. ![Run migration](https://kotlinlang.org/docs/images/run-migration-wn.png "Run migration")Code inspections have different [severity levels](https://www.jetbrains.com/help/idea/configuring-inspection-severities.html), to help you decide which suggestions to accept and which to ignore. ![Migration inspections](https://kotlinlang.org/docs/images/migration-inspection-wn.png "Migration inspections")Kotlin 1.4.0 is a [feature release](kotlin-evolution#feature-releases-and-incremental-releases) and therefore can bring incompatible changes to the language. Find the detailed list of such changes in the **[Compatibility Guide for Kotlin 1.4](compatibility-guide-14)**. Last modified: 10 January 2023 [What's new in Kotlin 1.4.20](whatsnew1420) [What's new in Kotlin 1.3](whatsnew13)
programming_docs
kotlin Composing suspending functions Composing suspending functions ============================== This section covers various approaches to composition of suspending functions. Sequential by default --------------------- Assume that we have two suspending functions defined elsewhere that do something useful like some kind of remote service call or computation. We just pretend they are useful, but actually each one just delays for a second for the purpose of this example: ``` suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` What do we do if we need them to be invoked *sequentially* — first `doSomethingUsefulOne` *and then* `doSomethingUsefulTwo`, and compute the sum of their results? In practice, we do this if we use the result of the first function to make a decision on whether we need to invoke the second one or to decide on how to invoke it. We use a normal sequential invocation, because the code in the coroutine, just like in the regular code, is *sequential* by default. The following example demonstrates it by measuring the total time it takes to execute both suspending functions: ``` import kotlinx.coroutines.* import kotlin.system.* fun main() = runBlocking<Unit> { //sampleStart val time = measureTimeMillis { val one = doSomethingUsefulOne() val two = doSomethingUsefulTwo() println("The answer is ${one + two}") } println("Completed in $time ms") //sampleEnd } suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` It produces something like this: ``` The answer is 42 Completed in 2017 ms ``` Concurrent using async ---------------------- What if there are no dependencies between invocations of `doSomethingUsefulOne` and `doSomethingUsefulTwo` and we want to get the answer faster, by doing both *concurrently*? This is where [async](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) comes to help. Conceptually, [async](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) is just like [launch](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html). It starts a separate coroutine which is a light-weight thread that works concurrently with all the other coroutines. The difference is that `launch` returns a [Job](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html) and does not carry any resulting value, while `async` returns a [Deferred](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html) — a light-weight non-blocking future that represents a promise to provide a result later. You can use `.await()` on a deferred value to get its eventual result, but `Deferred` is also a `Job`, so you can cancel it if needed. ``` import kotlinx.coroutines.* import kotlin.system.* fun main() = runBlocking<Unit> { //sampleStart val time = measureTimeMillis { val one = async { doSomethingUsefulOne() } val two = async { doSomethingUsefulTwo() } println("The answer is ${one.await() + two.await()}") } println("Completed in $time ms") //sampleEnd } suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` It produces something like this: ``` The answer is 42 Completed in 1017 ms ``` This is twice as fast, because the two coroutines execute concurrently. Note that concurrency with coroutines is always explicit. Lazily started async -------------------- Optionally, [async](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) can be made lazy by setting its `start` parameter to [CoroutineStart.LAZY](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-start/-l-a-z-y/index.html). In this mode it only starts the coroutine when its result is required by [await](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/await.html), or if its `Job`'s [start](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/start.html) function is invoked. Run the following example: ``` import kotlinx.coroutines.* import kotlin.system.* fun main() = runBlocking<Unit> { //sampleStart val time = measureTimeMillis { val one = async(start = CoroutineStart.LAZY) { doSomethingUsefulOne() } val two = async(start = CoroutineStart.LAZY) { doSomethingUsefulTwo() } // some computation one.start() // start the first one two.start() // start the second one println("The answer is ${one.await() + two.await()}") } println("Completed in $time ms") //sampleEnd } suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` It produces something like this: ``` The answer is 42 Completed in 1017 ms ``` So, here the two coroutines are defined but not executed as in the previous example, but the control is given to the programmer on when exactly to start the execution by calling [start](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/start.html). We first start `one`, then start `two`, and then await for the individual coroutines to finish. Note that if we just call [await](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/await.html) in `println` without first calling [start](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/start.html) on individual coroutines, this will lead to sequential behavior, since [await](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/await.html) starts the coroutine execution and waits for its finish, which is not the intended use-case for laziness. The use-case for `async(start = CoroutineStart.LAZY)` is a replacement for the standard `lazy` function in cases when computation of the value involves suspending functions. Async-style functions --------------------- We can define async-style functions that invoke `doSomethingUsefulOne` and `doSomethingUsefulTwo` *asynchronously* using the [async](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) coroutine builder using a [GlobalScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-global-scope/index.html) reference to opt-out of the structured concurrency. We name such functions with the "...Async" suffix to highlight the fact that they only start asynchronous computation and one needs to use the resulting deferred value to get the result. ``` // The result type of somethingUsefulOneAsync is Deferred<Int> @OptIn(DelicateCoroutinesApi::class) fun somethingUsefulOneAsync() = GlobalScope.async { doSomethingUsefulOne() } // The result type of somethingUsefulTwoAsync is Deferred<Int> @OptIn(DelicateCoroutinesApi::class) fun somethingUsefulTwoAsync() = GlobalScope.async { doSomethingUsefulTwo() } ``` Note that these `xxxAsync` functions are **not** *suspending* functions. They can be used from anywhere. However, their use always implies asynchronous (here meaning *concurrent*) execution of their action with the invoking code. The following example shows their use outside of coroutine: ``` import kotlinx.coroutines.* import kotlin.system.* //sampleStart // note that we don't have `runBlocking` to the right of `main` in this example fun main() { val time = measureTimeMillis { // we can initiate async actions outside of a coroutine val one = somethingUsefulOneAsync() val two = somethingUsefulTwoAsync() // but waiting for a result must involve either suspending or blocking. // here we use `runBlocking { ... }` to block the main thread while waiting for the result runBlocking { println("The answer is ${one.await() + two.await()}") } } println("Completed in $time ms") } //sampleEnd @OptIn(DelicateCoroutinesApi::class) fun somethingUsefulOneAsync() = GlobalScope.async { doSomethingUsefulOne() } @OptIn(DelicateCoroutinesApi::class) fun somethingUsefulTwoAsync() = GlobalScope.async { doSomethingUsefulTwo() } suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` Consider what happens if between the `val one = somethingUsefulOneAsync()` line and `one.await()` expression there is some logic error in the code, and the program throws an exception, and the operation that was being performed by the program aborts. Normally, a global error-handler could catch this exception, log and report the error for developers, but the program could otherwise continue doing other operations. However, here we have `somethingUsefulOneAsync` still running in the background, even though the operation that initiated it was aborted. This problem does not happen with structured concurrency, as shown in the section below. Structured concurrency with async --------------------------------- Let us take the [Concurrent using async](#concurrent-using-async) example and extract a function that concurrently performs `doSomethingUsefulOne` and `doSomethingUsefulTwo` and returns the sum of their results. Because the [async](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) coroutine builder is defined as an extension on [CoroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html), we need to have it in the scope and that is what the [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) function provides: ``` suspend fun concurrentSum(): Int = coroutineScope { val one = async { doSomethingUsefulOne() } val two = async { doSomethingUsefulTwo() } one.await() + two.await() } ``` This way, if something goes wrong inside the code of the `concurrentSum` function, and it throws an exception, all the coroutines that were launched in its scope will be cancelled. ``` import kotlinx.coroutines.* import kotlin.system.* fun main() = runBlocking<Unit> { //sampleStart val time = measureTimeMillis { println("The answer is ${concurrentSum()}") } println("Completed in $time ms") //sampleEnd } suspend fun concurrentSum(): Int = coroutineScope { val one = async { doSomethingUsefulOne() } val two = async { doSomethingUsefulTwo() } one.await() + two.await() } suspend fun doSomethingUsefulOne(): Int { delay(1000L) // pretend we are doing something useful here return 13 } suspend fun doSomethingUsefulTwo(): Int { delay(1000L) // pretend we are doing something useful here, too return 29 } ``` We still have concurrent execution of both operations, as evident from the output of the above `main` function: ``` The answer is 42 Completed in 1017 ms ``` Cancellation is always propagated through coroutines hierarchy: ``` import kotlinx.coroutines.* fun main() = runBlocking<Unit> { try { failedConcurrentSum() } catch(e: ArithmeticException) { println("Computation failed with ArithmeticException") } } suspend fun failedConcurrentSum(): Int = coroutineScope { val one = async<Int> { try { delay(Long.MAX_VALUE) // Emulates very long computation 42 } finally { println("First child was cancelled") } } val two = async<Int> { println("Second child throws an exception") throw ArithmeticException() } one.await() + two.await() } ``` Note how both the first `async` and the awaiting parent are cancelled on failure of one of the children (namely, `two`): ``` Second child throws an exception First child was cancelled Computation failed with ArithmeticException ``` Last modified: 10 January 2023 [Cancellation and timeouts](cancellation-and-timeouts) [Coroutine context and dispatchers](coroutine-context-and-dispatchers) kotlin Returns and jumps Returns and jumps ================= Kotlin has three structural jump expressions: * `return` by default returns from the nearest enclosing function or [anonymous function](lambdas#anonymous-functions). * `break` terminates the nearest enclosing loop. * `continue` proceeds to the next step of the nearest enclosing loop. All of these expressions can be used as part of larger expressions: ``` val s = person.name ?: return ``` The type of these expressions is the [Nothing type](exceptions#the-nothing-type). Break and continue labels ------------------------- Any expression in Kotlin may be marked with a *label*. Labels have the form of an identifier followed by the `@` sign, such as `abc@` or `fooBar@`. To label an expression, just add a label in front of it. ``` loop@ for (i in 1..100) { // ... } ``` Now, we can qualify a `break` or a `continue` with a label: ``` loop@ for (i in 1..100) { for (j in 1..100) { if (...) break@loop } } ``` A `break` qualified with a label jumps to the execution point right after the loop marked with that label. A `continue` proceeds to the next iteration of that loop. Return to labels ---------------- In Kotlin, functions can be nested using function literals, local functions, and object expressions. Qualified `return`s allow us to return from an outer function. The most important use case is returning from a lambda expression. Recall that when we write the following, the `return`-expression returns from the nearest enclosing function - `foo`: ``` //sampleStart fun foo() { listOf(1, 2, 3, 4, 5).forEach { if (it == 3) return // non-local return directly to the caller of foo() print(it) } println("this point is unreachable") } //sampleEnd fun main() { foo() } ``` Note that such non-local returns are supported only for lambda expressions passed to [inline functions](inline-functions). To return from a lambda expression, label it and qualify the `return`: ``` //sampleStart fun foo() { listOf(1, 2, 3, 4, 5).forEach lit@{ if (it == 3) return@lit // local return to the caller of the lambda - the forEach loop print(it) } print(" done with explicit label") } //sampleEnd fun main() { foo() } ``` Now, it returns only from the lambda expression. Often it is more convenient to use *implicit labels*, because such a label has the same name as the function to which the lambda is passed. ``` //sampleStart fun foo() { listOf(1, 2, 3, 4, 5).forEach { if (it == 3) return@forEach // local return to the caller of the lambda - the forEach loop print(it) } print(" done with implicit label") } //sampleEnd fun main() { foo() } ``` Alternatively, you can replace the lambda expression with an [anonymous function](lambdas#anonymous-functions). A `return` statement in an anonymous function will return from the anonymous function itself. ``` //sampleStart fun foo() { listOf(1, 2, 3, 4, 5).forEach(fun(value: Int) { if (value == 3) return // local return to the caller of the anonymous function - the forEach loop print(value) }) print(" done with anonymous function") } //sampleEnd fun main() { foo() } ``` Note that the use of local returns in the previous three examples is similar to the use of `continue` in regular loops. There is no direct equivalent for `break`, but it can be simulated by adding another nesting lambda and non-locally returning from it: ``` //sampleStart fun foo() { run loop@{ listOf(1, 2, 3, 4, 5).forEach { if (it == 3) return@loop // non-local return from the lambda passed to run print(it) } } print(" done with nested loop") } //sampleEnd fun main() { foo() } ``` When returning a value, the parser gives preference to the qualified return: ``` return@a 1 ``` This means "return `1` at label `@a`" rather than "return a labeled expression `(@a 1)`". Last modified: 10 January 2023 [Conditions and loops](control-flow) [Exceptions](exceptions) kotlin Immutability and concurrency in Kotlin/Native Immutability and concurrency in Kotlin/Native ============================================= Kotlin/Native implements strict mutability checks, ensuring the important invariant that the object is either immutable or accessible from the single thread at that moment in time (`mutable XOR global`). Immutability is a runtime property in Kotlin/Native, and can be applied to an arbitrary object subgraph using the `kotlin.native.concurrent.freeze` function. It makes all the objects reachable from the given one immutable. Such a transition is a one-way operation. For example, objects cannot be unfrozen later. Some naturally immutable objects such as `kotlin.String`, `kotlin.Int`, and other primitive types, along with `AtomicInt` and `AtomicReference`, are frozen by default. If a mutating operation is applied to a frozen object, an `InvalidMutabilityException` is thrown. To achieve `mutable XOR global` invariant, all globally visible states (currently, `object` singletons and enums) are automatically frozen. If object freezing is not desired, a `kotlin.native.ThreadLocal` annotation can be used, which will make the object state thread-local, and so, mutable (but the changed state is not visible to other threads). Top-level/global variables of non-primitive types are by default accessible in the main thread (i.e., the thread which initialized *Kotlin/Native* runtime first) only. Access from another thread will lead to an `IncorrectDereferenceException` being thrown. To make such variables accessible in other threads, you can use either the `@ThreadLocal` annotation and mark the value thread-local or `@SharedImmutable`, which will make the value frozen and accessible from other threads. See [Global variables and singletons](#global-variables-and-singletons). Class `AtomicReference` can be used to publish the changed frozen state to other threads and build patterns like shared caches. See [Atomic primitives and references](#atomic-primitives-and-references). Concurrency in Kotlin/Native ---------------------------- Kotlin/Native runtime doesn't encourage a classical thread-oriented concurrency model with mutually exclusive code blocks and conditional variables, as this model is known to be error-prone and unreliable. Instead, we suggest a collection of alternative approaches, allowing you to use hardware concurrency and implement blocking IO. Those approaches are as follows, and they will be elaborated on in further sections: ### Workers Instead of threads, Kotlin/Native runtime offers the concept of workers: concurrently executed control flow streams with an associated request queue. Workers are very similar to the actors in the Actor Model. A worker can exchange Kotlin objects with another worker so that at any moment, each mutable object is owned by a single worker, but ownership can be transferred. See section [Object transfer and freezing](#object-transfer-and-freezing). Once a worker is started with the `Worker.start` function call, it can be addressed with its own unique integer worker id. Other workers, or non-worker concurrency primitives, such as OS threads, can send a message to the worker with the `execute` call. ``` val future = execute(TransferMode.SAFE, { SomeDataForWorker() }) { // data returned by the second function argument comes to the // worker routine as 'input' parameter. input -> // Here we create an instance to be returned when someone consumes result future. WorkerResult(input.stringParam + " result") } future.consume { // Here we see result returned from routine above. Note that future object or // id could be transferred to another worker, so we don't have to consume future // in same execution context it was obtained. result -> println("result is $result") } ``` The call to `execute` uses a function passed as its second parameter to produce an object subgraph (for example, a set of mutually referring objects) which is then passed as a whole to that worker. It is then no longer available to the thread that initiated the request. This property is checked if the first parameter is `TransferMode.SAFE` by graph traversal and is just assumed to be true if it is `TransferMode.UNSAFE`. The last parameter to `execute` is a special Kotlin lambda, which is not allowed to capture any state and is actually invoked in the target worker's context. Once processed, the result is transferred to whatever consumes it in the future, and it is attached to the object graph of that worker/thread. If an object is transferred in `UNSAFE` mode and is still accessible from multiple concurrent executors, the program will likely crash unexpectedly, so consider that last resort in optimizing, not a general-purpose mechanism. ### Object transfer and freezing An important invariant that Kotlin/Native runtime maintains is that the object is either owned by a single thread/worker, or it is immutable (*shared XOR mutable*). This ensures that the same data has a single mutator, and so there is no need for locking to exist. To achieve such an invariant, we use the concept of not externally referred object subgraphs. This is a subgraph without external references from outside of the subgraph, which could be checked algorithmically with O(N) complexity (in ARC systems), where N is the number of elements in such a subgraph. Such subgraphs are usually produced as a result of a lambda expression, for example, some builder, and may not contain objects referred to externally. Freezing is a runtime operation making a given object subgraph immutable by modifying the object header so that future mutation attempts throw an `InvalidMutabilityException`. It is deep, so if an object has a pointer to other objects, the transitive closure of such objects will be frozen. Freezing is a one-way transformation; frozen objects cannot be unfrozen. Frozen objects have a nice property that, due to their immutability, they can be freely shared between multiple workers/threads without breaking the "mutable XOR shared" invariant. If an object is frozen, it can be checked with an extension property `isFrozen`, and if it is, object sharing is allowed. Currently, Kotlin/Native runtime only freezes the enum objects after creation, although additional auto-freezing of certain provably immutable objects could be implemented in the future. ### Object subgraph detachment An object subgraph without external references can be disconnected using `DetachedObjectGraph<T>` to a `COpaquePointer` value, which could be stored in `void*` data, so the disconnected object subgraphs can be stored in a C data structure, and later attached back with `DetachedObjectGraph<T>.attach()` in an arbitrary thread or a worker. Together with [raw memory sharing](#raw-shared-memory), it allows side-channel object transfer between concurrent threads if the worker mechanisms are insufficient for a particular task. Note that object detachment may require an explicit leaving function holding object references and then performing cyclic garbage collection. For example, code like: ``` val graph = DetachedObjectGraph { val map = mutableMapOf<String, String>() for (entry in map.entries) { // ... } map } ``` will not work as expected and will throw runtime exception, as there are uncollected cycles in the detached graph, while: ``` val graph = DetachedObjectGraph { { val map = mutableMapOf<String, String>() for (entry in map.entries) { // ... } map }().also { kotlin.native.internal.GC.collect() } } ``` will work properly, as holding references will be released, and then cyclic garbage affecting the reference counter is collected. ### Raw shared memory Considering the strong ties between Kotlin/Native and C via interoperability, in conjunction with the other mechanisms mentioned above, it is possible to build popular data structures, like concurrent hashmap or shared cache, with Kotlin/Native. It is possible to rely upon shared C data and store references to detached object subgraphs in it. Consider the following .def file: ``` package = global --- typedef struct { int version; void* kotlinObject; } SharedData; SharedData sharedData; ``` After running the cinterop tool, it can share Kotlin data in a versionized global structure, and interact with it from Kotlin transparently via autogenerated Kotlin like this: ``` class SharedData(rawPtr: NativePtr) : CStructVar(rawPtr) { var version: Int var kotlinObject: COpaquePointer? } ``` So in combination with the top-level variable declared above, it can allow looking at the same memory from different threads and building traditional concurrent structures with platform-specific synchronization primitives. ### Global variables and singletons Frequently, global variables are a source of unintended concurrency issues, so *Kotlin/Native* implements the following mechanisms to prevent the unintended sharing of state via global objects: * global variables, unless specially marked, can be only accessed from the main thread (that is, the thread *Kotlin/Native* runtime was first initialized), if other thread access such a global, `IncorrectDereferenceException` is thrown * for global variables marked with the `@kotlin.native.ThreadLocal` annotation, each thread keeps a thread-local copy, so changes are not visible between threads * for global variables marked with the `@kotlin.native.SharedImmutable` annotation value is shared, but frozen before publishing, so each thread sees the same value * singleton objects unless marked with `@kotlin.native.ThreadLocal` are frozen and shared, lazy values allowed, unless cyclic frozen structures were attempted to be created * enums are always frozen These mechanisms combined allow natural race-free programming with code reuse across platforms in Multiplatform projects. ### Atomic primitives and references Kotlin/Native standard library provides primitives for safe working with concurrently mutable data, namely `AtomicInt`, `AtomicLong`, `AtomicNativePtr`, `AtomicReference` and `FreezableAtomicReference` in the package `kotlin.native.concurrent`. Atomic primitives allow concurrency-safe update operations, such as increment, decrement, and compare-and-swap, along with value setters and getters. Atomic primitives are always considered frozen by the runtime, and while their fields can be updated with the regular `field.value += 1`, it is not concurrency safe. The value must be changed using dedicated operations so it is possible to perform concurrent-safe global counters and similar data structures. Some algorithms require shared mutable references across multiple workers. For example, the global mutable configuration could be implemented as an immutable instance of properties list atomically replaced with the new version on configuration update as the whole in a single transaction. This way, no inconsistent configuration could be seen, and at the same time, the configuration could be updated as needed. To achieve such functionality, Kotlin/Native runtime provides two related classes: `kotlin.native.concurrent.AtomicReference` and `kotlin.native.concurrent.FreezableAtomicReference`. Atomic reference holds a reference to a frozen or immutable object, and its value could be updated by set or compare-and-swap operation. Thus, a dedicated set of objects could be used to create mutable shared object graphs (of immutable objects). Cycles in the shared memory could be created using atomic references. Kotlin/Native runtime doesn't support garbage collecting cyclic data when the reference cycle goes through `AtomicReference` or frozen `FreezableAtomicReference`. So to avoid memory leaks, atomic references that are potentially parts of shared cyclic data should be zeroed out once no longer needed. If atomic reference value is attempted to be set to a non-frozen value, a runtime exception is thrown. Freezable atomic reference is similar to the regular atomic reference until frozen behaves like a regular box for a reference. After freezing, it behaves like an atomic reference and can only hold a reference to a frozen object. Last modified: 10 January 2023 [Migrate to the new memory manager](native-migration-guide) [Concurrency overview](multiplatform-mobile-concurrency-overview)
programming_docs
kotlin KSP examples KSP examples ============ Get all member functions ------------------------ ``` fun KSClassDeclaration.getDeclaredFunctions(): List<KSFunctionDeclaration> = declarations.filterIsInstance<KSFunctionDeclaration>() ``` Check whether a class or function is local ------------------------------------------ ``` fun KSDeclaration.isLocal(): Boolean = parentDeclaration != null && parentDeclaration !is KSClassDeclaration ``` Find the actual class or interface declaration that the type alias points to ---------------------------------------------------------------------------- ``` fun KSTypeAlias.findActualType(): KSClassDeclaration { val resolvedType = this.type.resolve().declaration return if (resolvedType is KSTypeAlias) { resolvedType.findActualType() } else { resolvedType as KSClassDeclaration } } ``` Collect suppressed names in a file annotation --------------------------------------------- ``` // @file:kotlin.Suppress("Example1", "Example2") fun KSFile.suppressedNames(): List<String> { val ignoredNames = mutableListOf<String>() annotations.filter { it.shortName.asString() == "Suppress" && it.annotationType.resolve()?.declaration?.qualifiedName?.asString() == "kotlin.Suppress" }.forEach { val argValues: List<String> = it.arguments.flatMap { it.value } ignoredNames.addAll(argValues) } return ignoredNames } ``` Last modified: 10 January 2023 [Why KSP](ksp-why-ksp) [How KSP models Kotlin code](ksp-additional-details) kotlin Sealed classes Sealed classes ============== *Sealed* classes and interfaces represent restricted class hierarchies that provide more control over inheritance. All direct subclasses of a sealed class are known at compile time. No other subclasses may appear outside a module within which the sealed class is defined. For example, third-party clients can't extend your sealed class in their code. Thus, each instance of a sealed class has a type from a limited set that is known when this class is compiled. The same works for sealed interfaces and their implementations: once a module with a sealed interface is compiled, no new implementations can appear. In some sense, sealed classes are similar to [`enum`](enum-classes) classes: the set of values for an enum type is also restricted, but each enum constant exists only as a *single instance*, whereas a subclass of a sealed class can have *multiple* instances, each with its own state. As an example, consider a library's API. It's likely to contain error classes to let the library users handle errors that it can throw. If the hierarchy of such error classes includes interfaces or abstract classes visible in the public API, then nothing prevents implementing or extending them in the client code. However, the library doesn't know about errors declared outside it, so it can't treat them consistently with its own classes. With a sealed hierarchy of error classes, library authors can be sure that they know all possible error types and no other ones can appear later. To declare a sealed class or interface, put the `sealed` modifier before its name: ``` sealed interface Error sealed class IOError(): Error class FileReadError(val file: File): IOError() class DatabaseError(val source: DataSource): IOError() object RuntimeError : Error ``` A sealed class is [abstract](classes#abstract-classes) by itself, it cannot be instantiated directly and can have `abstract` members. Constructors of sealed classes can have one of two [visibilities](visibility-modifiers): `protected` (by default) or `private`: ``` sealed class IOError { constructor() { /*...*/ } // protected by default private constructor(description: String): this() { /*...*/ } // private is OK // public constructor(code: Int): this() {} // Error: public and internal are not allowed } ``` Location of direct subclasses ----------------------------- Direct subclasses of sealed classes and interfaces must be declared in the same package. They may be top-level or nested inside any number of other named classes, named interfaces, or named objects. Subclasses can have any [visibility](visibility-modifiers) as long as they are compatible with normal inheritance rules in Kotlin. Subclasses of sealed classes must have a proper qualified name. They can't be local nor anonymous objects. These restrictions don't apply to indirect subclasses. If a direct subclass of a sealed class is not marked as sealed, it can be extended in any way that its modifiers allow: ``` sealed interface Error // has implementations only in same package and module sealed class IOError(): Error // extended only in same package and module open class CustomError(): Error // can be extended wherever it's visible ``` ### Inheritance in multiplatform projects There is one more inheritance restriction in [multiplatform projects](multiplatform-get-started): direct subclasses of sealed classes must reside in the same source set. It applies to sealed classes without the [`expect` and `actual` modifiers](multiplatform-connect-to-apis). If a sealed class is declared as `expect` in a common source set and have `actual` implementations in platform source sets, both `expect` and `actual` versions can have subclasses in their source sets. Moreover, if you use a [hierarchical structure](multiplatform-share-on-platforms#share-code-on-similar-platforms), you can create subclasses in any source set between the `expect` and `actual` declarations. [Learn more about the hierarchical structure of multiplatform projects](multiplatform-share-on-platforms#share-code-on-similar-platforms). Sealed classes and when expression ---------------------------------- The key benefit of using sealed classes comes into play when you use them in a [`when`](control-flow#when-expression) expression. If it's possible to verify that the statement covers all cases, you don't need to add an `else` clause to the statement. However, this works only if you use `when` as an expression (using the result) and not as a statement: ``` fun log(e: Error) = when(e) { is FileReadError -> { println("Error while reading file ${e.file}") } is DatabaseError -> { println("Error while reading from database ${e.source}") } is RuntimeError -> { println("Runtime error") } // the `else` clause is not required because all the cases are covered } ``` Last modified: 10 January 2023 [Data classes](data-classes) [Generics: in, out, where](generics) kotlin Retrieve collection parts Retrieve collection parts ========================= The Kotlin standard library contains extension functions for retrieving parts of a collection. These functions provide a variety of ways to select elements for the result collection: listing their positions explicitly, specifying the result size, and others. Slice ----- [`slice()`](../api/latest/jvm/stdlib/kotlin.collections/slice) returns a list of the collection elements with given indices. The indices may be passed either as a [range](ranges) or as a collection of integer values. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.slice(1..3)) println(numbers.slice(0..4 step 2)) println(numbers.slice(setOf(3, 5, 0))) //sampleEnd } ``` Take and drop ------------- To get the specified number of elements starting from the first, use the [`take()`](../api/latest/jvm/stdlib/kotlin.collections/take) function. For getting the last elements, use [`takeLast()`](../api/latest/jvm/stdlib/kotlin.collections/take-last). When called with a number larger than the collection size, both functions return the whole collection. To take all the elements except a given number of first or last elements, call the [`drop()`](../api/latest/jvm/stdlib/kotlin.collections/drop) and [`dropLast()`](../api/latest/jvm/stdlib/kotlin.collections/drop-last) functions respectively. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.take(3)) println(numbers.takeLast(3)) println(numbers.drop(1)) println(numbers.dropLast(5)) //sampleEnd } ``` You can also use predicates to define the number of elements for taking or dropping. There are four functions similar to the ones described above: * [`takeWhile()`](../api/latest/jvm/stdlib/kotlin.collections/take-while) is `take()` with a predicate: it takes the elements up to but excluding the first one not matching the predicate. If the first collection element doesn't match the predicate, the result is empty. * [`takeLastWhile()`](../api/latest/jvm/stdlib/kotlin.collections/take-last-while) is similar to `takeLast()`: it takes the range of elements matching the predicate from the end of the collection. The first element of the range is the element next to the last element not matching the predicate. If the last collection element doesn't match the predicate, the result is empty; * [`dropWhile()`](../api/latest/jvm/stdlib/kotlin.collections/drop-while) is the opposite to `takeWhile()` with the same predicate: it returns the elements from the first one not matching the predicate to the end. * [`dropLastWhile()`](../api/latest/jvm/stdlib/kotlin.collections/drop-last-while) is the opposite to `takeLastWhile()` with the same predicate: it returns the elements from the beginning to the last one not matching the predicate. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.takeWhile { !it.startsWith('f') }) println(numbers.takeLastWhile { it != "three" }) println(numbers.dropWhile { it.length == 3 }) println(numbers.dropLastWhile { it.contains('i') }) //sampleEnd } ``` Chunked ------- To break a collection into parts of a given size, use the [`chunked()`](../api/latest/jvm/stdlib/kotlin.collections/chunked) function. `chunked()` takes a single argument – the size of the chunk – and returns a `List` of `List`s of the given size. The first chunk starts from the first element and contains the `size` elements, the second chunk holds the next `size` elements, and so on. The last chunk may have a smaller size. ``` fun main() { //sampleStart val numbers = (0..13).toList() println(numbers.chunked(3)) //sampleEnd } ``` You can also apply a transformation for the returned chunks right away. To do this, provide the transformation as a lambda function when calling `chunked()`. The lambda argument is a chunk of the collection. When `chunked()` is called with a transformation, the chunks are short-living `List`s that should be consumed right in that lambda. ``` fun main() { //sampleStart val numbers = (0..13).toList() println(numbers.chunked(3) { it.sum() }) // `it` is a chunk of the original collection //sampleEnd } ``` Windowed -------- You can retrieve all possible ranges of the collection elements of a given size. The function for getting them is called [`windowed()`](../api/latest/jvm/stdlib/kotlin.collections/windowed): it returns a list of element ranges that you would see if you were looking at the collection through a sliding window of the given size. Unlike `chunked()`, `windowed()` returns element ranges (*windows*) starting from *each* collection element. All the windows are returned as elements of a single `List`. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five") println(numbers.windowed(3)) //sampleEnd } ``` `windowed()` provides more flexibility with optional parameters: * `step` defines a distance between first elements of two adjacent windows. By default the value is 1, so the result contains windows starting from all elements. If you increase the step to 2, you will receive only windows starting from odd elements: first, third, and so on. * `partialWindows` includes windows of smaller sizes that start from the elements at the end of the collection. For example, if you request windows of three elements, you can't build them for the last two elements. Enabling `partialWindows` in this case includes two more lists of sizes 2 and 1. Finally, you can apply a transformation to the returned ranges right away. To do this, provide the transformation as a lambda function when calling `windowed()`. ``` fun main() { //sampleStart val numbers = (1..10).toList() println(numbers.windowed(3, step = 2, partialWindows = true)) println(numbers.windowed(3) { it.sum() }) //sampleEnd } ``` To build two-element windows, there is a separate function - [`zipWithNext()`](../api/latest/jvm/stdlib/kotlin.collections/zip-with-next). It creates pairs of adjacent elements of the receiver collection. Note that `zipWithNext()` doesn't break the collection into pairs; it creates a `Pair` for *each* element except the last one, so its result on `[1, 2, 3, 4]` is `[[1, 2], [2, 3], [3, 4]]`, not `[[1, 2`], `[3, 4]]`. `zipWithNext()` can be called with a transformation function as well; it should take two elements of the receiver collection as arguments. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five") println(numbers.zipWithNext()) println(numbers.zipWithNext() { s1, s2 -> s1.length > s2.length}) //sampleEnd } ``` Last modified: 10 January 2023 [Grouping](collection-grouping) [Retrieve single elements](collection-elements) kotlin Create an app using C Interop and libcurl – tutorial Create an app using C Interop and libcurl – tutorial ==================================================== This tutorial demonstrates how to use IntelliJ IDEA to create a command-line application. You'll learn how to create a simple HTTP client that can run natively on specified platforms using Kotlin/Native and the `libcurl` library. The output will be an executable command-line app that you can run on macOS and Linux and make simple HTTP GET requests. To get started, install the latest version of [IntelliJ IDEA](https://www.jetbrains.com/idea/download/index.html). The tutorial is suitable for both IntelliJ IDEA Community Edition and IntelliJ IDEA Ultimate. Create a Kotlin/Native project ------------------------------ 1. In IntelliJ IDEA, select **File | New | Project**. 2. In the panel on the left, select **Kotlin Multiplatform | Native Application**. 3. Specify the name and select the folder where you'll save your application. ![New project. Native application in IntelliJ IDEA](https://kotlinlang.org/docs/images/native-file-new.png "New project. Native application in IntelliJ IDEA") 4. Click **Next** and then **Finish**. IntelliJ IDEA will create a new project with the files and folders you need to get you started. It's important to understand that an application written in Kotlin/Native can target different platforms if the code does not have platform-specific requirements. Your code is placed in a folder named `NativeMain` with its corresponding `NativeTest`. For this tutorial, keep the folder structure as is. ![Native application project structure](https://kotlinlang.org/docs/images/native-project-structure.png "Native application project structure")Along with your new project, a `build.gradle(.kts)` file is generated. Pay special attention to the following in the build file: ``` kotlin { val hostOs = System.getProperty("os.name") val isMingwX64 = hostOs.startsWith("Windows") val nativeTarget = when { hostOs == "Mac OS X" -> macosX64("native") hostOs == "Linux" -> linuxX64("native") isMingwX64 -> mingwX64("native") else -> throw GradleException("Host OS is not supported in Kotlin/Native.") } nativeTarget.apply { binaries { executable { entryPoint = "main" } } } } ``` ``` kotlin { def hostOs = System.getProperty("os.name") def isMingwX64 = hostOs.startsWith("Windows") def nativeTarget if (hostOs == "Mac OS X") nativeTarget = macosX64('native') else if (hostOs == "Linux") nativeTarget = linuxX64("native") else if (isMingwX64) nativeTarget = mingwX64("native") else throw new FileNotFoundException("Host OS is not supported in Kotlin/Native.") nativeTarget.with { binaries { executable { entryPoint = 'main' } } } } ``` * Targets are defined using `macOSX64`, `linuxX64`, and `mingwX64` for macOS, Linux, and Windows. For a complete list of supported platforms, see the [Kotlin Native overview](native-overview#target-platforms). * The entry itself defines a series of properties to indicate how the binary is generated and the entry point of the applications. These can be left as default values. * C interoperability is configured as an additional step in the build. By default, all the symbols from C are imported to the `interop` package. You may want to import the whole package in `.kt` files. Learn more about [how to configure](multiplatform-discover-project#multiplatform-plugin) it. Create a definition file ------------------------ When writing native applications, you often need access to certain functionalities that are not included in the [Kotlin standard library](../api/latest/jvm/stdlib/index), such as making HTTP requests, reading and writing from disk, and so on. Kotlin/Native helps consume standard C libraries, opening up an entire ecosystem of functionality that exists for pretty much anything you may need. Kotlin/Native is already shipped with a set of prebuilt [platform libraries](native-platform-libs), which provide some additional common functionality to the standard library. An ideal scenario for interop is to call C functions as if you are calling Kotlin functions, following the same signature and conventions. This is when the `cinterop` tool comes in handy. It takes a C library and generates the corresponding Kotlin bindings, so that the library can be used as if it were Kotlin code. To generate these bindings, create a library definition `.def` file that contains some information about the necessary headers. In this app, you'll need the `libcurl` library to make some HTTP calls. To create a definition file: 1. Select the `src` folder and create a new directory with **File | New | Directory**. 2. Name new directory **nativeInterop/cinterop**. This is the default convention for header file locations, though it can be overridden in the `build.gradle` file if you use a different location. 3. Select this new subfolder and create a new `libcurl.def` file with **File | New | File**. 4. Update your file with the following code: ``` headers = curl/curl.h headerFilter = curl/* compilerOpts.linux = -I/usr/include -I/usr/include/x86_64-linux-gnu linkerOpts.osx = -L/opt/local/lib -L/usr/local/opt/curl/lib -lcurl linkerOpts.linux = -L/usr/lib/x86_64-linux-gnu -lcurl ``` * `headers` is the list of header files to generate Kotlin stubs. You can add multiple files to this entry, separating each with a `\` on a new line. In this case, it's only `curl.h`. The referenced files need to be available on the system path (in this case, it's `/usr/include/curl`). * `headerFilter` shows what exactly is included. In C, all the headers are also included when one file references another one with the `#include` directive. Sometimes it's not necessary, and you can add this parameter [using glob patterns](https://en.wikipedia.org/wiki/Glob_(programming)) to fine-tune things. `headerFilter` is an optional argument and is mostly used when the library is installed as a system library. You don't want to fetch external dependencies (such as system `stdint.h` header) into the interop library. It may be important to optimize the library size and fix potential conflicts between the system and the provided Kotlin/Native compilation environment. * The next lines are about providing linker and compiler options, which can vary depending on different target platforms. In this case, they are macOS (the `.osx` suffix) and Linux (the `.linux` suffix). Parameters without a suffix are also possible (for example, `linkerOpts=`) and applied to all platforms. The convention is that each library gets its definition file, usually with the same name as the library. For more information on all the options available to `cinterop`, see [the Interop section](native-c-interop). Add interoperability to the build process ----------------------------------------- To use header files, make sure they are generated as a part of the build process. For this, add the following entry to the `build.gradle(.kts)` file: ``` nativeTarget.apply { compilations.getByName("main") { // NL cinterops { // NL val libcurl by creating // NL } // NL } // NL binaries { executable { entryPoint = "main" } } } ``` ``` nativeTarget.with { compilations.main { // NL cinterops { // NL libcurl // NL } // NL } // NL binaries { executable { entryPoint = 'main' } } } ``` The new lines are marked with `// NL`. First, `cinterops` is added, and then an entry for each `def` file. By default, the name of the file is used. You can override this with additional parameters: ``` val libcurl by creating { defFile(project.file("src/nativeInterop/cinterop/libcurl.def")) packageName("com.jetbrains.handson.http") compilerOpts("-I/path") includeDirs.allHeaders("path") } ``` ``` libcurl { defFile project.file("src/nativeInterop/cinterop/libcurl.def") packageName 'com.jetbrains.handson.http' compilerOpts '-I/path' includeDirs.allHeaders("path") } ``` See the [Interoperability with C](native-c-interop) section for more details on the available options. Write the application code -------------------------- Now you have the library and the corresponding Kotlin stubs and can use them from your application. For this tutorial, convert the [simple.c](https://curl.haxx.se/libcurl/c/simple.html) example to Kotlin. In the `src/nativeMain/kotlin/` folder, update your `Main.kt` file with the following code: ``` import kotlinx.cinterop.* import libcurl.* fun main(args: Array<String>) { val curl = curl_easy_init() if (curl != null) { curl_easy_setopt(curl, CURLOPT_URL, "https://example.com") curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L) val res = curl_easy_perform(curl) if (res != CURLE_OK) { println("curl_easy_perform() failed ${curl_easy_strerror(res)?.toKString()}") } curl_easy_cleanup(curl) } } ``` As you can see, explicit variable declarations are eliminated in the Kotlin version, but everything else is pretty much the same as the C version. All the calls you'd expect in the `libcurl` library are available in the Kotlin equivalent. Compile and run the application ------------------------------- 1. Compile the application. To do that, run the following command in the terminal: ``` ./gradlew runDebugExecutableNative ``` In this case, the `cinterop` generated part is implicitly included in the build. 2. If there are no errors during compilation, click the green **Run** icon in the gutter beside the `main()` method or use the **Alt+Enter** shortcut to invoke the launch menu in IntelliJ IDEA. IntelliJ IDEA opens the **Run** tab and shows the output — the contents of `https://example.com`: ![Application output with HTML-code](https://kotlinlang.org/docs/images/native-output.png "Application output with HTML-code") You can see the actual output because the call `curl_easy_perform` prints the result to the standard output. You could hide this using `curl_easy_setopt`. Last modified: 10 January 2023 [Mapping Strings from C – tutorial](mapping-strings-from-c) [Interoperability with Swift/Objective-C](native-objc-interop)
programming_docs
kotlin Collections overview Collections overview ==================== The Kotlin Standard Library provides a comprehensive set of tools for managing *collections* – groups of a variable number of items (possibly zero) that are significant to the problem being solved and are commonly operated on. Collections are a common concept for most programming languages, so if you're familiar with, for example, Java or Python collections, you can skip this introduction and proceed to the detailed sections. A collection usually contains a number of objects (this number may also be zero) of the same type. Objects in a collection are called *elements* or *items*. For example, all the students in a department form a collection that can be used to calculate their average age. The following collection types are relevant for Kotlin: * *List* is an ordered collection with access to elements by indices – integer numbers that reflect their position. Elements can occur more than once in a list. An example of a list is a telephone number: it's a group of digits, their order is important, and they can repeat. * *Set* is a collection of unique elements. It reflects the mathematical abstraction of set: a group of objects without repetitions. Generally, the order of set elements has no significance. For example, the numbers on lottery tickets form a set: they are unique, and their order is not important. * *Map* (or *dictionary*) is a set of key-value pairs. Keys are unique, and each of them maps to exactly one value. The values can be duplicates. Maps are useful for storing logical connections between objects, for example, an employee's ID and their position. Kotlin lets you manipulate collections independently of the exact type of objects stored in them. In other words, you add a `String` to a list of `String`s the same way as you would do with `Int`s or a user-defined class. So, the Kotlin Standard Library offers generic interfaces, classes, and functions for creating, populating, and managing collections of any type. The collection interfaces and related functions are located in the `kotlin.collections` package. Let's get an overview of its contents. Collection types ---------------- The Kotlin Standard Library provides implementations for basic collection types: sets, lists, and maps. A pair of interfaces represent each collection type: * A *read-only* interface that provides operations for accessing collection elements. * A *mutable* interface that extends the corresponding read-only interface with write operations: adding, removing, and updating its elements. Note that altering a mutable collection doesn't require it to be a [`var`](basic-syntax#variables): write operations modify the same mutable collection object, so the reference doesn't change. Although, if you try to reassign a `val` collection, you'll get a compilation error. ``` fun main() { //sampleStart val numbers = mutableListOf("one", "two", "three", "four") numbers.add("five") // this is OK println(numbers) //numbers = mutableListOf("six", "seven") // compilation error //sampleEnd } ``` The read-only collection types are [covariant](generics#variance). This means that, if a `Rectangle` class inherits from `Shape`, you can use a `List<Rectangle>` anywhere the `List<Shape>` is required. In other words, the collection types have the same subtyping relationship as the element types. Maps are covariant on the value type, but not on the key type. In turn, mutable collections aren't covariant; otherwise, this would lead to runtime failures. If `MutableList<Rectangle>` was a subtype of `MutableList<Shape>`, you could insert other `Shape` inheritors (for example, `Circle`) into it, thus violating its `Rectangle` type argument. Below is a diagram of the Kotlin collection interfaces: ![Collection interfaces hierarchy](https://kotlinlang.org/docs/images/collections-diagram.png "Collection interfaces hierarchy")Let's walk through the interfaces and their implementations. To learn about `Collection`, read the section below. To learn about `List`, `Set`, and `Map`, you can either read the corresponding sections or watch a video by Sebastian Aigner, Kotlin Developer Advocate: ### Collection [`Collection<T>`](../api/latest/jvm/stdlib/kotlin.collections/-collection/index) is the root of the collection hierarchy. This interface represents the common behavior of a read-only collection: retrieving size, checking item membership, and so on. `Collection` inherits from the `Iterable<T>` interface that defines the operations for iterating elements. You can use `Collection` as a parameter of a function that applies to different collection types. For more specific cases, use the `Collection`'s inheritors: [`List`](../api/latest/jvm/stdlib/kotlin.collections/-list/index) and [`Set`](../api/latest/jvm/stdlib/kotlin.collections/-set/index). ``` fun printAll(strings: Collection<String>) { for(s in strings) print("$s ") println() } fun main() { val stringList = listOf("one", "two", "one") printAll(stringList) val stringSet = setOf("one", "two", "three") printAll(stringSet) } ``` [`MutableCollection<T>`](../api/latest/jvm/stdlib/kotlin.collections/-mutable-collection/index) is a `Collection` with write operations, such as `add` and `remove`. ``` fun List<String>.getShortWordsTo(shortWords: MutableList<String>, maxLength: Int) { this.filterTo(shortWords) { it.length <= maxLength } // throwing away the articles val articles = setOf("a", "A", "an", "An", "the", "The") shortWords -= articles } fun main() { val words = "A long time ago in a galaxy far far away".split(" ") val shortWords = mutableListOf<String>() words.getShortWordsTo(shortWords, 3) println(shortWords) } ``` ### List [`List<T>`](../api/latest/jvm/stdlib/kotlin.collections/-list/index) stores elements in a specified order and provides indexed access to them. Indices start from zero – the index of the first element – and go to `lastIndex` which is the `(list.size - 1)`. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four") println("Number of elements: ${numbers.size}") println("Third element: ${numbers.get(2)}") println("Fourth element: ${numbers[3]}") println("Index of element \"two\" ${numbers.indexOf("two")}") //sampleEnd } ``` List elements (including nulls) can duplicate: a list can contain any number of equal objects or occurrences of a single object. Two lists are considered equal if they have the same sizes and [structurally equal](equality#structural-equality) elements at the same positions. ``` data class Person(var name: String, var age: Int) fun main() { //sampleStart val bob = Person("Bob", 31) val people = listOf(Person("Adam", 20), bob, bob) val people2 = listOf(Person("Adam", 20), Person("Bob", 31), bob) println(people == people2) bob.age = 32 println(people == people2) //sampleEnd } ``` [`MutableList<T>`](../api/latest/jvm/stdlib/kotlin.collections/-mutable-list/index) is a `List` with list-specific write operations, for example, to add or remove an element at a specific position. ``` fun main() { //sampleStart val numbers = mutableListOf(1, 2, 3, 4) numbers.add(5) numbers.removeAt(1) numbers[0] = 0 numbers.shuffle() println(numbers) //sampleEnd } ``` As you see, in some aspects lists are very similar to arrays. However, there is one important difference: an array's size is defined upon initialization and is never changed; in turn, a list doesn't have a predefined size; a list's size can be changed as a result of write operations: adding, updating, or removing elements. In Kotlin, the default implementation of `MutableList` is [`ArrayList`](../api/latest/jvm/stdlib/kotlin.collections/-array-list/index) which you can think of as a resizable array. ### Set [`Set<T>`](../api/latest/jvm/stdlib/kotlin.collections/-set/index) stores unique elements; their order is generally undefined. `null` elements are unique as well: a `Set` can contain only one `null`. Two sets are equal if they have the same size, and for each element of a set there is an equal element in the other set. ``` fun main() { //sampleStart val numbers = setOf(1, 2, 3, 4) println("Number of elements: ${numbers.size}") if (numbers.contains(1)) println("1 is in the set") val numbersBackwards = setOf(4, 3, 2, 1) println("The sets are equal: ${numbers == numbersBackwards}") //sampleEnd } ``` [`MutableSet`](../api/latest/jvm/stdlib/kotlin.collections/-mutable-set/index) is a `Set` with write operations from `MutableCollection`. The default implementation of `MutableSet` – [`LinkedHashSet`](../api/latest/jvm/stdlib/kotlin.collections/-linked-hash-set/index) – preserves the order of elements insertion. Hence, the functions that rely on the order, such as `first()` or `last()`, return predictable results on such sets. ``` fun main() { //sampleStart val numbers = setOf(1, 2, 3, 4) // LinkedHashSet is the default implementation val numbersBackwards = setOf(4, 3, 2, 1) println(numbers.first() == numbersBackwards.first()) println(numbers.first() == numbersBackwards.last()) //sampleEnd } ``` An alternative implementation – [`HashSet`](../api/latest/jvm/stdlib/kotlin.collections/-hash-set/index) – says nothing about the elements order, so calling such functions on it returns unpredictable results. However, `HashSet` requires less memory to store the same number of elements. ### Map [`Map<K, V>`](../api/latest/jvm/stdlib/kotlin.collections/-map/index) is not an inheritor of the `Collection` interface; however, it's a Kotlin collection type as well. A `Map` stores *key-value* pairs (or *entries*); keys are unique, but different keys can be paired with equal values. The `Map` interface provides specific functions, such as access to value by key, searching keys and values, and so on. ``` fun main() { //sampleStart val numbersMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3, "key4" to 1) println("All keys: ${numbersMap.keys}") println("All values: ${numbersMap.values}") if ("key2" in numbersMap) println("Value by key \"key2\": ${numbersMap["key2"]}") if (1 in numbersMap.values) println("The value 1 is in the map") if (numbersMap.containsValue(1)) println("The value 1 is in the map") // same as previous //sampleEnd } ``` Two maps containing the equal pairs are equal regardless of the pair order. ``` fun main() { //sampleStart val numbersMap = mapOf("key1" to 1, "key2" to 2, "key3" to 3, "key4" to 1) val anotherMap = mapOf("key2" to 2, "key1" to 1, "key4" to 1, "key3" to 3) println("The maps are equal: ${numbersMap == anotherMap}") //sampleEnd } ``` [`MutableMap`](../api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index) is a `Map` with map write operations, for example, you can add a new key-value pair or update the value associated with the given key. ``` fun main() { //sampleStart val numbersMap = mutableMapOf("one" to 1, "two" to 2) numbersMap.put("three", 3) numbersMap["one"] = 11 println(numbersMap) //sampleEnd } ``` The default implementation of `MutableMap` – [`LinkedHashMap`](../api/latest/jvm/stdlib/kotlin.collections/-linked-hash-map/index) – preserves the order of elements insertion when iterating the map. In turn, an alternative implementation – [`HashMap`](../api/latest/jvm/stdlib/kotlin.collections/-hash-map/index) – says nothing about the elements order. Last modified: 10 January 2023 [Kotlin roadmap](roadmap) [Constructing collections](constructing-collections) kotlin Learning Kotlin with EduTools plugin Learning Kotlin with EduTools plugin ==================================== With the [EduTools plugin](https://plugins.jetbrains.com/plugin/10081-edutools), available both in [Android Studio](https://developer.android.com/studio) and [IntelliJ IDEA](https://www.jetbrains.com/idea/), you can learn Kotlin through code practicing tasks. Take a look at the [Learner Start Guide](https://plugins.jetbrains.com/plugin/10081-edutools/docs/learner-start-guide.html?section=Kotlin%20Koans), which will get you started with the Kotlin Koans course inside IntelliJ IDEA. Solve interactive coding challenges and get instant feedback right inside the IDE. If you want to use the EduTools plugin for teaching, read [Teaching Kotlin with EduTools plugin](edu-tools-educator). Last modified: 10 January 2023 [Advent of Code puzzles in idiomatic Kotlin](advent-of-code) [Teaching Kotlin with EduTools plugin](edu-tools-educator) kotlin Type checks and casts Type checks and casts ===================== is and !is operators -------------------- Use the `is` operator or its negated form `!is` to perform a runtime check that identifies whether an object conforms to a given type: ``` if (obj is String) { print(obj.length) } if (obj !is String) { // same as !(obj is String) print("Not a String") } else { print(obj.length) } ``` Smart casts ----------- In most cases, you don't need to use explicit cast operators in Kotlin because the compiler tracks the `is`-checks and [explicit casts](#unsafe-cast-operator) for immutable values and inserts (safe) casts automatically when necessary: ``` fun demo(x: Any) { if (x is String) { print(x.length) // x is automatically cast to String } } ``` The compiler is smart enough to know that a cast is safe if a negative check leads to a return: ``` if (x !is String) return print(x.length) // x is automatically cast to String ``` or if it is on the right-hand side of `&&` or `||` and the proper check (regular or negative) is on the left-hand side: ``` // x is automatically cast to String on the right-hand side of `||` if (x !is String || x.length == 0) return // x is automatically cast to String on the right-hand side of `&&` if (x is String && x.length > 0) { print(x.length) // x is automatically cast to String } ``` Smart casts work for [`when` expressions](control-flow#when-expression) and [`while` loops](control-flow#while-loops) as well: ``` when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } ``` Note that smart casts work only when the compiler can guarantee that the variable won't change between the check and the usage. More specifically, smart casts can be used under the following conditions: * `val` local variables - always, with the exception of [local delegated properties](delegated-properties). * `val` properties - if the property is private or internal or if the check is performed in the same [module](visibility-modifiers#modules) where the property is declared. Smart casts cannot be used on open properties or properties that have custom getters. * `var` local variables - if the variable is not modified between the check and the usage, is not captured in a lambda that modifies it, and is not a local delegated property. * `var` properties - never, because the variable can be modified at any time by other code. "Unsafe" cast operator ---------------------- Usually, the cast operator throws an exception if the cast isn't possible. And so, it's called *unsafe*. The unsafe cast in Kotlin is done by the infix operator `as`. ``` val x: String = y as String ``` Note that `null` cannot be cast to `String`, as this type is not [nullable](null-safety). If `y` is null, the code above throws an exception. To make code like this correct for null values, use the nullable type on the right-hand side of the cast: ``` val x: String? = y as String? ``` "Safe" (nullable) cast operator ------------------------------- To avoid exceptions, use the *safe* cast operator `as?`, which returns `null` on failure. ``` val x: String? = y as? String ``` Note that despite the fact that the right-hand side of `as?` is a non-null type `String`, the result of the cast is nullable. Generics type checks and casts ------------------------------ Please see the corresponding section in the [generics documentation page](generics#generics-type-checks-and-casts) for information on which type checks and casts you can perform with generics. Last modified: 10 January 2023 [Unsigned integer types](unsigned-integer-types) [Conditions and loops](control-flow) kotlin Compatibility modes Compatibility modes =================== When a big team is migrating onto a new version, it may appear in an "inconsistent state" at some point, when some developers have already updated but others haven't. To prevent the former from writing and committing code that others may not be able to compile, we provide the following command line switches (also available in the IDE and [Gradle](gradle-compiler-options)/[Maven](maven#specifying-compiler-options)): * `-language-version X.Y` - compatibility mode for Kotlin language version X.Y, reports errors for all language features that came out later. * `-api-version X.Y` - compatibility mode for Kotlin API version X.Y, reports errors for all code using newer APIs from the Kotlin Standard Library (including the code generated by the compiler). Currently, we support the development for three previous language and API versions in addition to the latest stable one. *Below, we use OV for "Older Version", and NV for "Newer Version".* Binary compatibility warnings ----------------------------- If you use the NV Kotlin compiler and have the OV standard library or the OV reflection library in the classpath, it can be a sign that the project is misconfigured. To prevent unexpected problems during compilation or at runtime, we suggest either updating the dependencies to NV, or specifying the API version / language version arguments explicitly. Otherwise, the compiler detects that something can go wrong and reports a warning. For example, if OV = 1.0 and NV = 1.1, you can observe one of the following warnings: * `Runtime JAR files in the classpath have the version 1.0, which is older than the API version 1.1. Consider using the runtime of version 1.1, or pass '-api-version 1.0' explicitly to restrict the available APIs to the runtime of version 1.0.` This means that you're using the Kotlin compiler 1.1 against the standard or reflection library of version 1.0. This can be handled in different ways: + If you intend to use the APIs from the 1.1 Standard Library, or language features that depend on those APIs, you should upgrade the dependency to the version 1.1. + If you want to keep your code compatible with the 1.0 standard library, you can pass `-api-version 1.0`. + If you've just upgraded to Kotlin 1.1 but can not use new language features yet (e.g. because some of your teammates may not have upgraded), you can pass `-language-version 1.0`, which will restrict all APIs and language features to 1.0. * `Runtime JAR files in the classpath should have the same version. These files were found in the classpath: kotlin-reflect.jar (version 1.0) kotlin-stdlib.jar (version 1.1) Consider providing an explicit dependency on kotlin-reflect 1.1 to prevent strange errors Some runtime JAR files in the classpath have an incompatible version. Consider removing them from the classpath` This means that you have a dependency on libraries of different versions, for example the 1.1 standard library and the 1.0 reflection library. To prevent subtle errors at runtime, we recommend you to use the same version of all Kotlin libraries. In this case, consider adding an explicit dependency on the 1.1 reflection library. * `Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version of the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath` This means that there's a library in the classpath which does not depend on the Kotlin standard library as a Gradle/Maven dependency, but is distributed in the same artifact with it (i.e. has it *bundled*). Such a library may cause issues because standard build tools do not consider it an instance of the Kotlin standard library, thus it's not subject to the dependency version resolution mechanisms, and you can end up with several versions of the same library in the classpath. Consider contacting the authors of such a library and suggesting to use the Gradle/Maven dependency instead. Last modified: 10 January 2023 [Compatibility guide for Kotlin 1.3](compatibility-guide-13) [What is cross-platform mobile development?](cross-platform-mobile-development)
programming_docs
kotlin Delegation Delegation ========== The [Delegation pattern](https://en.wikipedia.org/wiki/Delegation_pattern) has proven to be a good alternative to implementation inheritance, and Kotlin supports it natively requiring zero boilerplate code. A class `Derived` can implement an interface `Base` by delegating all of its public members to a specified object: ``` interface Base { fun print() } class BaseImpl(val x: Int) : Base { override fun print() { print(x) } } class Derived(b: Base) : Base by b fun main() { val b = BaseImpl(10) Derived(b).print() } ``` The `by`-clause in the supertype list for `Derived` indicates that `b` will be stored internally in objects of `Derived` and the compiler will generate all the methods of `Base` that forward to `b`. Overriding a member of an interface implemented by delegation ------------------------------------------------------------- [Overrides](inheritance#overriding-methods) work as you expect: the compiler will use your `override` implementations instead of those in the delegate object. If you want to add `override fun printMessage() { print("abc") }` to `Derived`, the program would print *abc* instead of *10* when `printMessage` is called: ``` interface Base { fun printMessage() fun printMessageLine() } class BaseImpl(val x: Int) : Base { override fun printMessage() { print(x) } override fun printMessageLine() { println(x) } } class Derived(b: Base) : Base by b { override fun printMessage() { print("abc") } } fun main() { val b = BaseImpl(10) Derived(b).printMessage() Derived(b).printMessageLine() } ``` Note, however, that members overridden in this way do not get called from the members of the delegate object, which can only access its own implementations of the interface members: ``` interface Base { val message: String fun print() } class BaseImpl(val x: Int) : Base { override val message = "BaseImpl: x = $x" override fun print() { println(message) } } class Derived(b: Base) : Base by b { // This property is not accessed from b's implementation of `print` override val message = "Message of Derived" } fun main() { val b = BaseImpl(10) val derived = Derived(b) derived.print() println(derived.message) } ``` Learn more about [delegated properties](delegated-properties). Last modified: 10 January 2023 [Object expressions and declarations](object-declarations) [Delegated properties](delegated-properties) kotlin Multiple round processing Multiple round processing ========================= KSP supports *multiple round processing*, or processing files over multiple rounds. It means that subsequent rounds use an output from previous rounds as additional input. Changes to your processor ------------------------- To use multiple round processing, the `SymbolProcessor.process()` function needs to return a list of deferred symbols (`List<KSAnnotated>`) for invalid symbols. Use `KSAnnotated.validate()` to filter invalid symbols to be deferred to the next round. The following sample code shows how to defer invalid symbols by using a validation check: ``` override fun process(resolver: Resolver): List<KSAnnotated> { val symbols = resolver.getSymbolsWithAnnotation("com.example.annotation.Builder") val result = symbols.filter { !it.validate() } symbols .filter { it is KSClassDeclaration && it.validate() } .map { it.accept(BuilderVisitor(), Unit) } return result } ``` Multiple round behavior ----------------------- ### Deferring symbols to the next round Processors can defer the processing of certain symbols to the next round. When a symbol is deferred, processor is waiting for other processors to provide additional information. It can continue deferring the symbol as many rounds as needed. Once the other processors provide the required information, the processor can then process the deferred symbol. Processor should only defer invalid symbols which are lacking necessary information. Therefore, processors should **not** defer symbols from classpath, KSP will also filter out any deferred symbols that are not from source code. As an example, a processor that creates a builder for an annotated class might require all parameter types of its constructors to be valid (resolved to a concrete type). In the first round, one of the parameter type is not resolvable. Then in the second round, it becomes resolvable because of the generated files from the first round. ### Validating symbols A convenient way to decide if a symbol should be deferred is through validation. A processor should know which information is necessary to properly process the symbol. Note that validation usually requires resolution which can be expensive, so we recommend checking only what is required. Continuing with the previous example, an ideal validation for the builder processor checks only whether all resolved parameter types of the constructors of annotated symbols contain `isError == false`. KSP provides a default validation utility. For more information, see the [Advanced](#advanced) section. ### Termination condition Multiple round processing terminates when a full round of processing generates no new files. If unprocessed deferred symbols still exist when the termination condition is met, KSP logs an error message for each processor with unprocessed deferred symbols. ### Files accessible at each round Both newly generated files and existing files are accessible through a `Resolver`. KSP provides two APIs for accessing files: `Resolver.getAllFiles()` and `Resolver.getNewFiles()`. `getAllFiles()` returns a combined list of both existing files and newly generated files, while `getNewFiles()` returns only newly generated files. ### Changes to getSymbolsAnnotatedWith() To avoid unnecessary reprocessing of symbols, `getSymbolsAnnotatedWith()` returns only those symbols found in newly generated files, together with the symbols from deferred symbols from the last round. ### Processor instantiating A processor instance is created only once, which means you can store information in the processor object to be used for later rounds. ### Information consistent cross rounds All KSP symbols will not be reusable across multiple rounds, as the resolution result can potentially change based on what was generated in a previous round. However, since KSP does not allow modifying existing code, some information such as the string value for a symbol name should still be reusable. To summarize, processors can store information from previous rounds but need to bear in mind that this information might be invalid in future rounds. ### Error and exception handling When an error (defined by processor calling `KSPLogger.error()`) or exception occurs, processing stops after the current round completes. All processors will call the `onError()` method and will **not** call the `finish()` method. Note that even though an error has occurred, other processors continue processing normally for that round. This means that error handling occurs after processing has completed for the round. Upon exceptions, KSP will try to distinguish the exceptions from KSP and exceptions from processors. Exceptions will result in a termination of processing immediately and be logged as an error in KSPLogger. Exceptions from KSP should be reported to KSP developers for further investigation. At the end of the round where exceptions or errors happened, all processors will invoke onError() function to do their own error handling. KSP provides a default no-op implementation for `onError()` as part of the `SymbolProcessor` interface. You can override this method to provide your own error handling logic. Advanced -------- ### Default behavior for validation The default validation logic provided by KSP validates all directly reachable symbols inside the enclosing scope of the symbol that is being validated. Default validation checks whether references in the enclosed scope are resolvable to a concrete type but does not recursively dive into the referenced types to perform validation. ### Write your own validation logic Default validation behavior might not be suitable for all cases. You can reference `KSValidateVisitor` and write your own validation logic by providing a custom `predicate` lambda, which is then used by `KSValidateVisitor` to filter out symbols that need to be checked. Last modified: 10 January 2023 [Incremental processing](ksp-incremental) [KSP with Kotlin Multiplatform](ksp-multiplatform) kotlin JavaScript modules JavaScript modules ================== You can compile your Kotlin projects to JavaScript modules for various popular module systems. We currently support the following configurations for JavaScript modules: * [Unified Module Definitions (UMD)](https://github.com/umdjs/umd), which is compatible with both *AMD* and *CommonJS*. UMD modules are also able to be executed without being imported or when no module system is present. This is the default option for the `browser` and `nodejs` targets. * [Asynchronous Module Definitions (AMD)](https://github.com/amdjs/amdjs-api/wiki/AMD), which is in particular used by the [RequireJS](https://requirejs.org/) library. * [CommonJS](http://wiki.commonjs.org/wiki/Modules/1.1), widely used by Node.js/npm (`require` function and `module.exports` object) * Plain. Don't compile for any module system. You can access a module by its name in the global scope. Browser targets --------------- If you're targeting the browser and want to use a different module system than UMD, you can specify the desired module type in the `webpackTask` configuration block. For example, to switch to CommonJS, use: ``` kotlin { js { browser { webpackTask { output.libraryTarget = "commonjs2" } } binaries.executable() } } ``` Webpack provides two different "flavors" of CommonJS, `commonjs` and `commonjs2`, which affect the way your declarations are made available. While in most cases, you probably want `commonjs2`, which adds the `module.exports` syntax to the generated library, you can also opt for the "pure" `commonjs` option, which implements the CommonJS specification exactly. To learn more about the difference between `commonjs` and `commonjs2`, check [here](https://github.com/webpack/webpack/issues/1114). JavaScript libraries and Node.js files -------------------------------------- If you are creating a library that will be consumed from JavaScript or a Node.js file, and want to use a different module system, the instructions are slightly different. ### Choose the target module system To select module kind, set the `moduleKind` compiler option in the Gradle build script. ``` tasks.named<KotlinJsCompile>("compileKotlinJs").configure { compilerOptions.moduleKind.set(org.jetbrains.kotlin.gradle.dsl.JsModuleKind.MODULE_COMMONJS) } ``` ``` compileKotlinJs.compilerOptions.moduleKind = org.jetbrains.kotlin.gradle.dsl.JsModuleKind.MODULE_COMMONJS ``` Available values are: `umd` (default), `commonjs`, `amd`, `plain`. In the Kotlin Gradle DSL, there is also a shortcut for setting the CommonJS module kind: ``` kotlin { js { useCommonJs() // . . . } } ``` @JsModule annotation -------------------- To tell Kotlin that an `external` class, package, function or property is a JavaScript module, you can use `@JsModule` annotation. Consider you have the following CommonJS module called "hello": ``` module.exports.sayHello = function(name) { alert("Hello, " + name); } ``` You should declare it like this in Kotlin: ``` @JsModule("hello") external fun sayHello(name: String) ``` ### Apply @JsModule to packages Some JavaScript libraries export packages (namespaces) instead of functions and classes. In terms of JavaScript, it's an *object* that has *members* that are classes, functions and properties. Importing these packages as Kotlin objects often looks unnatural. The compiler can map imported JavaScript packages to Kotlin packages, using the following notation: ``` @file:JsModule("extModule") package ext.jspackage.name external fun foo() external class C ``` where the corresponding JavaScript module is declared like this: ``` module.exports = { foo: { /* some code here */ }, C: { /* some code here */ } } ``` Files marked with `@file:JsModule` annotation can't declare non-external members. The example below produces a compile-time error: ``` @file:JsModule("extModule") package ext.jspackage.name external fun foo() fun bar() = "!" + foo() + "!" // error here ``` ### Import deeper package hierarchies In the previous example the JavaScript module exports a single package. However, some JavaScript libraries export multiple packages from within a module. This case is also supported by Kotlin, though you have to declare a new `.kt` file for each package you import. For example, let's make the example a bit more complicated: ``` module.exports = { mylib: { pkg1: { foo: function() { /* some code here */ }, bar: function() { /* some code here */ } }, pkg2: { baz: function() { /* some code here */ } } } } ``` To import this module in Kotlin, you have to write two Kotlin source files: ``` @file:JsModule("extModule") @file:JsQualifier("mylib.pkg1") package extlib.pkg1 external fun foo() external fun bar() ``` and ``` @file:JsModule("extModule") @file:JsQualifier("mylib.pkg2") package extlib.pkg2 external fun baz() ``` ### @JsNonModule annotation When a declaration is marked as `@JsModule`, you can't use it from Kotlin code when you don't compile it to a JavaScript module. Usually, developers distribute their libraries both as JavaScript modules and downloadable `.js` files that you can copy to your project's static resources and include via a `<script>` tag. To tell Kotlin that it's okay to use a `@JsModule` declaration from a non-module environment, add the `@JsNonModule` annotation. For example, consider the following JavaScript code: ``` function topLevelSayHello(name) { alert("Hello, " + name); } if (module && module.exports) { module.exports = topLevelSayHello; } ``` You could describe it from Kotlin as follows: ``` @JsModule("hello") @JsNonModule @JsName("topLevelSayHello") external fun sayHello(name: String) ``` ### Module system used by the Kotlin Standard Library Kotlin is distributed with the Kotlin/JS standard library as a single file, which is itself compiled as an UMD module, so you can use it with any module system described above. While for most use cases of Kotlin/JS, it is recommended to use a Gradle dependency on `kotlin-stdlib-js`, it is also available on NPM as the [`kotlin`](https://www.npmjs.com/package/kotlin) package. Last modified: 10 January 2023 [Use Kotlin code from JavaScript](js-to-kotlin-interop) [Kotlin/JS reflection](js-reflection) kotlin Migrate to the new memory manager Migrate to the new memory manager ================================= This guide compares the new [Kotlin/Native memory manager](native-memory-manager) with the legacy one and describes how to migrate your projects. The most noticeable change in the new memory manager is lifting restrictions on object sharing. You don't need to freeze objects to share them between threads, specifically: * Top-level properties can be accessed and modified by any thread without using `@SharedImmutable`. * Objects passing through interop can be accessed and modified by any thread without freezing them. * `Worker.executeAfter` no longer requires operations to be frozen. * `Worker.execute` no longer requires producers to return an isolated object subgraph. * Reference cycles containing `AtomicReference` and `FreezableAtomicReference` do not cause memory leaks. Apart from easy object sharing, the new memory manager also brings other major changes: * Global properties are initialized lazily when the file they are defined in is accessed first. Previously global properties were initialized at the program startup. As a workaround, you can mark properties that must be initialized at the program start with the `@EagerInitialization` annotation. Before using, check its [documentation](../api/latest/jvm/stdlib/kotlin.native/-eager-initialization/index). * `by lazy {}` properties support thread-safety modes and do not handle unbounded recursion. * Exceptions that escape `operation` in `Worker.executeAfter` are processed like in other runtime parts, by trying to execute a user-defined unhandled exception hook or terminating the program if the hook was not found or failed with an exception itself. * Freezing is deprecated, disabled by default, and will be removed in future releases. Do not use freezing if you don't need your code to work with the [legacy memory manager](#support-both-new-and-legacy-memory-managers). Follow these guidelines to migrate your projects from the legacy memory manager: Update Kotlin ------------- The new Kotlin/Native memory manager has been enabled by default since Kotlin 1.7.20. Check the Kotlin version and [update to the latest one](releases#update-to-a-new-release) if necessary. Update dependencies ------------------- kotlinx.coroutines Update to version 1.6.0 or later. Do not use versions with the `native-mt` suffix. There are also some specifics with the new memory manager you should keep in mind: * Every common primitive (channels, flows, coroutines) works through the Worker boundaries, since freezing is not required. * `Dispatchers.Default` is backed by a pool of Workers on Linux and Windows and by a global queue on Apple targets. * Use `newSingleThreadContext` to create a coroutine dispatcher that is backed by a Worker. * Use `newFixedThreadPoolContext` to create a coroutine dispatcher backed by a pool of `N` Workers. * `Dispatchers.Main` is backed by the main queue on Darwin and by a standalone Worker on other platforms. Ktor Update to version 2.0 or later. Other dependencies The majority of libraries should work without any changes, however, there might be exceptions. Make sure that you update dependencies to the latest versions, and there is no difference between library versions for the legacy and the new memory manager. Update your code ---------------- To support the new memory manager, remove usages of the affected API: | Old API | What to do | | --- | --- | | [`@SharedImmutable`](../api/latest/jvm/stdlib/kotlin.native.concurrent/-shared-immutable/index) | You can remove all usages, though there are no warnings for using this API in the new memory manager. | | [The `FreezableAtomicReference` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-freezable-atomic-reference/index) | Use [`AtomicReference`](../api/latest/jvm/stdlib/kotlin.native.concurrent/-atomic-reference/index) instead. | | [The `FreezingException` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-freezing-exception/index) | Remove all usages. | | | [The `InvalidMutabilityException` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-invalid-mutability-exception/index) | Remove all usages. | | [The `IncorrectDereferenceException` class](../api/latest/jvm/stdlib/kotlin.native/-incorrect-dereference-exception/index) | Remove all usages. | | [The `freeze()` function](../api/latest/jvm/stdlib/kotlin.native.concurrent/freeze) | Remove all usages. | | [The `isFrozen` property](../api/latest/jvm/stdlib/kotlin.native.concurrent/is-frozen) | You can remove all usages. Since freezing is deprecated, the property always returns `false`. | | [The `ensureNeverFrozen()` function](../api/latest/jvm/stdlib/kotlin.native.concurrent/ensure-never-frozen) | Remove all usages. | | [The `atomicLazy()` function](../api/latest/jvm/stdlib/kotlin.native.concurrent/atomic-lazy) | Use [`lazy()`](../api/latest/jvm/stdlib/kotlin/lazy) instead. | | [The `MutableData` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-mutable-data/index) | Use any regular collection instead. | | [The `WorkerBoundReference<out T : Any>` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-worker-bound-reference/index) | Use `T` directly. | | [The `DetachedObjectGraph<T>` class](../api/latest/jvm/stdlib/kotlin.native.concurrent/-detached-object-graph/index) | Use `T` directly. To pass the value through the C interop, use [the StableRef class](../api/latest/jvm/stdlib/kotlinx.cinterop/-stable-ref/index). | Support both new and legacy memory managers ------------------------------------------- If you're a library author and need to maintain support for the legacy memory manager or want to have a fallback in case of issues with the new memory manager, you can temporarily support code for both new and legacy memory managers. To ignore deprecation warnings, do one of the following: * Annotate usages of the deprecated API with `@OptIn(FreezingIsDeprecated::class)`. * Apply `languageSettings.optIn("kotlin.native.FreezingIsDeprecated")` to all the Kotlin source sets in Gradle. * Pass the compiler flag `-opt-in=kotlin.native.FreezingIsDeprecated`. See [Opt-in requirements](opt-in-requirements) for more details. What's next ----------- * [Learn about the new memory manager](native-memory-manager) * [Configure integration with iOS](native-ios-integration) Last modified: 10 January 2023 [iOS integration](native-ios-integration) [Immutability and concurrency in Kotlin/Native](native-immutability)
programming_docs
kotlin Java annotation processing to KSP reference Java annotation processing to KSP reference =========================================== Program elements ---------------- | **Java** | **Closest facility in KSP** | **Notes** | | --- | --- | --- | | `AnnotationMirror` | `KSAnnotation` | | | `AnnotationValue` | `KSValueArguments` | | | `Element` | `KSDeclaration`/`KSDeclarationContainer` | | | `ExecutableElement` | `KSFunctionDeclaration` | | | `PackageElement` | `KSFile` | KSP doesn't model packages as program elements | | `Parameterizable` | `KSDeclaration` | | | `QualifiedNameable` | `KSDeclaration` | | | `TypeElement` | `KSClassDeclaration` | | | `TypeParameterElement` | `KSTypeParameter` | | | `VariableElement` | `KSValueParameter`/`KSPropertyDeclaration` | | Types ----- KSP requires explicit type resolution, so some functionalities in Java can only be carried out by `KSType` and the corresponding elements before resolution. | **Java** | **Closest facility in KSP** | **Notes** | | --- | --- | --- | | `ArrayType` | `KSBuiltIns.arrayType` | | | `DeclaredType` | `KSType`/`KSClassifierReference` | | | `ErrorType` | `KSType.isError` | | | `ExecutableType` | `KSType`/`KSCallableReference` | | | `IntersectionType` | `KSType`/`KSTypeParameter` | | | `NoType` | `KSType.isError` | N/A in KSP | | `NullType` | | N/A in KSP | | `PrimitiveType` | `KSBuiltIns` | Not exactly same as primitive type in Java | | `ReferenceType` | `KSTypeReference` | | | `TypeMirror` | `KSType` | | | `TypeVariable` | `KSTypeParameter` | | | `UnionType` | N/A | Kotlin has only one type per catch block. `UnionType` is also not observable by even Java annotation processors | | `WildcardType` | `KSType`/`KSTypeArgument` | | Misc ---- | **Java** | **Closest facility in KSP** | **Notes** | | --- | --- | --- | | `Name` | `KSName` | | | `ElementKind` | `ClassKind`/`FunctionKind` | | | `Modifier` | `Modifier` | | | `NestingKind` | `ClassKind`/`FunctionKind` | | | `AnnotationValueVisitor` | | | | `ElementVisitor` | `KSVisitor` | | | `AnnotatedConstruct` | `KSAnnotated` | | | `TypeVisitor` | | | | `TypeKind` | `KSBuiltIns` | Some can be found in builtins, otherwise check `KSClassDeclaration` for `DeclaredType` | | `ElementFilter` | `Collection.filterIsInstance` | | | `ElementKindVisitor` | `KSVisitor` | | | `ElementScanner` | `KSTopDownVisitor` | | | `SimpleAnnotationValueVisitor` | | Not needed in KSP | | `SimpleElementVisitor` | `KSVisitor` | | | `SimpleTypeVisitor` | | | | `TypeKindVisitor` | | | | `Types` | `Resolver`/`utils` | Some of the `utils` are also integrated into symbol interfaces | | `Elements` | `Resolver`/`utils` | | Details ------- See how functionalities of Java annotation processing API can be carried out by KSP. ### AnnotationMirror | **Java** | **KSP equivalent** | | --- | --- | | `getAnnotationType` | `ksAnnotation.annotationType` | | `getElementValues` | `ksAnnotation.arguments` | ### AnnotationValue | **Java** | **KSP equivalent** | | --- | --- | | `getValue` | `ksValueArgument.value` | ### Element | **Java** | **KSP equivalent** | | --- | --- | | `asType` | `ksClassDeclaration.asType(...)` is available for `KSClassDeclaration` only. Type arguments need to be supplied. | | `getAnnotation` | To be implemented | | `getAnnotationMirrors` | `ksDeclaration.annotations` | | `getEnclosedElements` | `ksDeclarationContainer.declarations` | | `getEnclosingElements` | `ksDeclaration.parentDeclaration` | | `getKind` | Type check and cast following `ClassKind` or `FunctionKind` | | `getModifiers` | `ksDeclaration.modifiers` | | `getSimpleName` | `ksDeclaration.simpleName` | ### ExecutableElement | **Java** | **KSP equivalent** | | --- | --- | | `getDefaultValue` | To be implemented | | `getParameters` | `ksFunctionDeclaration.parameters` | | `getReceiverType` | `ksFunctionDeclaration.parentDeclaration` | | `getReturnType` | `ksFunctionDeclaration.returnType` | | `getSimpleName` | `ksFunctionDeclaration.simpleName` | | `getThrownTypes` | Not needed in Kotlin | | `getTypeParameters` | `ksFunctionDeclaration.typeParameters` | | `isDefault` | Check whether parent declaration is an interface or not | | `isVarArgs` | `ksFunctionDeclaration.parameters.any { it.isVarArg }` | ### Parameterizable | **Java** | **KSP equivalent** | | --- | --- | | `getTypeParameters` | `ksFunctionDeclaration.typeParameters` | ### QualifiedNameable | **Java** | **KSP equivalent** | | --- | --- | | `getQualifiedName` | `ksDeclaration.qualifiedName` | ### TypeElement | **Java** | **KSP equivalent** | | --- | --- | | `getEnclosedElements` | `ksClassDeclaration.declarations` | | `getEnclosingElement` | `ksClassDeclaration.parentDeclaration` | | `getInterfaces` | ``` // Should be able to do without resolution ksClassDeclaration.superTypes .map { it.resolve() } .filter { (it?.declaration as? KSClassDeclaration)?.classKind == ClassKind.INTERFACE } ``` | | `getNestingKind` | Check `KSClassDeclaration.parentDeclaration` and `inner` modifier | | `getQualifiedName` | `ksClassDeclaration.qualifiedName` | | `getSimpleName` | `ksClassDeclaration.simpleName` | | `getSuperclass` | ``` // Should be able to do without resolution ksClassDeclaration.superTypes .map { it.resolve() } .filter { (it?.declaration as? KSClassDeclaration)?.classKind == ClassKind.CLASS } ``` | | `getTypeParameters` | `ksClassDeclaration.typeParameters` | ### TypeParameterElement | **Java** | **KSP equivalent** | | --- | --- | | `getBounds` | `ksTypeParameter.bounds` | | `getEnclosingElement` | `ksTypeParameter.parentDeclaration` | | `getGenericElement` | `ksTypeParameter.parentDeclaration` | ### VariableElement | **Java** | **KSP equivalent** | | --- | --- | | `getConstantValue` | To be implemented | | `getEnclosingElement` | `ksValueParameter.parentDeclaration` | | `getSimpleName` | `ksValueParameter.simpleName` | ### ArrayType | **Java** | **KSP equivalent** | | --- | --- | | `getComponentType` | `ksType.arguments.first()` | ### DeclaredType | **Java** | **KSP equivalent** | | --- | --- | | `asElement` | `ksType.declaration` | | `getEnclosingType` | `ksType.declaration.parentDeclaration` | | `getTypeArguments` | `ksType.arguments` | ### ExecutableType | **Java** | **KSP equivalent** | | --- | --- | | `getParameterTypes` | `ksType.declaration.typeParameters`, `ksFunctionDeclaration.parameters.map { it.type }` | | `getReceiverType` | `ksFunctionDeclaration.parentDeclaration.asType(...)` | | `getReturnType` | `ksType.declaration.typeParameters.last()` | | `getThrownTypes` | Not needed in Kotlin | | `getTypeVariables` | `ksFunctionDeclaration.typeParameters` | ### IntersectionType | **Java** | **KSP equivalent** | | --- | --- | | `getBounds` | `ksTypeParameter.bounds` | ### TypeMirror | **Java** | **KSP equivalent** | | --- | --- | | `getKind` | Compare with types in `KSBuiltIns` for primitive types, `Unit` type, otherwise declared types | ### TypeVariable | **Java** | **KSP equivalent** | | --- | --- | | `asElement` | `ksType.declaration` | | `getLowerBound` | To be decided. Only needed if capture is provided and explicit bound checking is needed. | | `getUpperBound` | `ksTypeParameter.bounds` | ### WildcardType | **Java** | **KSP equivalent** | | --- | --- | | `getExtendsBound` | ``` if (ksTypeArgument.variance == Variance.COVARIANT) ksTypeArgument.type else null ``` | | `getSuperBound` | ``` if (ksTypeArgument.variance == Variance.CONTRAVARIANT) ksTypeArgument.type else null ``` | ### Elements | **Java** | **KSP equivalent** | | --- | --- | | `getAllAnnotationMirrors` | `KSDeclarations.annotations` | | `getAllMembers` | `getAllFunctions`, `getAllProperties` is to be implemented | | `getBinaryName` | To be decided, see [Java Specification](https://docs.oracle.com/javase/specs/jls/se13/html/jls-13.html#jls-13.1) | | `getConstantExpression` | There is constant value, not expression | | `getDocComment` | To be implemented | | `getElementValuesWithDefaults` | To be implemented | | `getName` | `resolver.getKSNameFromString` | | `getPackageElement` | Package not supported, while package information can be retrieved. Operation on package is not possible for KSP | | `getPackageOf` | Package not supported | | `getTypeElement` | `Resolver.getClassDeclarationByName` | | `hides` | To be implemented | | `isDeprecated` | ``` KsDeclaration.annotations.any { it.annotationType.resolve()!!.declaration.qualifiedName!!.asString() == Deprecated::class.qualifiedName } ``` | | `overrides` | `KSFunctionDeclaration.overrides`/`KSPropertyDeclaration.overrides` (member function of respective class) | | `printElements` | KSP has basic `toString()` implementation on most classes | ### Types | **Java** | **KSP equivalent** | | --- | --- | | `asElement` | `ksType.declaration` | | `asMemberOf` | `resolver.asMemberOf` | | `boxedClass` | Not needed | | `capture` | To be decided | | `contains` | `KSType.isAssignableFrom` | | `directSuperTypes` | `(ksType.declaration as KSClassDeclaration).superTypes` | | `erasure` | `ksType.starProjection()` | | `getArrayType` | `ksBuiltIns.arrayType.replace(...)` | | `getDeclaredType` | `ksClassDeclaration.asType` | | `getNoType` | `ksBuiltIns.nothingType`/`null` | | `getNullType` | Depending on the context, `KSType.markNullable` could be useful | | `getPrimitiveType` | Not needed, check for `KSBuiltins` | | `getWildcardType` | Use `Variance` in places expecting `KSTypeArgument` | | `isAssignable` | `ksType.isAssignableFrom` | | `isSameType` | `ksType.equals` | | `isSubsignature` | `functionTypeA == functionTypeB`/`functionTypeA == functionTypeB.starProjection()` | | `isSubtype` | `ksType.isAssignableFrom` | | `unboxedType` | Not needed | Last modified: 10 January 2023 [How KSP models Kotlin code](ksp-additional-details) [Incremental processing](ksp-incremental) kotlin Use Kotlin code from JavaScript Use Kotlin code from JavaScript =============================== Depending on the selected [JavaScript Module](js-modules) system, the Kotlin/JS compiler generates different output. But in general, the Kotlin compiler generates normal JavaScript classes, functions and properties, which you can freely use from JavaScript code. There are some subtle things you should remember, though. Isolating declarations in a separate JavaScript object in plain mode -------------------------------------------------------------------- If you have explicitly set your module kind to be `plain`, Kotlin creates an object that contains all Kotlin declarations from the current module. This is done to prevent spoiling the global object. This means that for a module `myModule`, all declarations are available to JavaScript via the `myModule` object. For example: ``` fun foo() = "Hello" ``` Can be called from JavaScript like this: ``` alert(myModule.foo()); ``` This is not applicable when you compile your Kotlin module to JavaScript modules like UMD (which is the default setting for both `browser` and `nodejs` targets), CommonJS or AMD. In this case, your declarations will be exposed in the format specified by your chosen JavaScript module system. When using UMD or CommonJS, for example, your call site could look like this: ``` alert(require('myModule').foo()); ``` Check the article on [JavaScript Modules](js-modules) for more information on the topic of JavaScript module systems. Package structure ----------------- Kotlin exposes its package structure to JavaScript, so unless you define your declarations in the root package, you have to use fully qualified names in JavaScript. For example: ``` package my.qualified.packagename fun foo() = "Hello" ``` When using UMD or CommonJS, for example, your callsite could look like this: ``` alert(require('myModule').my.qualified.packagename.foo()) ``` Or, in the case of using `plain` as a module system setting: ``` alert(myModule.my.qualified.packagename.foo()); ``` ### @JsName annotation In some cases (for example, to support overloads), the Kotlin compiler mangles the names of generated functions and attributes in JavaScript code. To control the generated names, you can use the `@JsName` annotation: ``` // Module 'kjs' class Person(val name: String) { fun hello() { println("Hello $name!") } @JsName("helloWithGreeting") fun hello(greeting: String) { println("$greeting $name!") } } ``` Now you can use this class from JavaScript in the following way: ``` // If necessary, import 'kjs' according to chosen module system var person = new kjs.Person("Dmitry"); // refers to module 'kjs' person.hello(); // prints "Hello Dmitry!" person.helloWithGreeting("Servus"); // prints "Servus Dmitry!" ``` If we didn't specify the `@JsName` annotation, the name of the corresponding function would contain a suffix calculated from the function signature, for example `hello_61zpoe$`. Note that there are some cases in which the Kotlin compiler does not apply mangling: * `external` declarations are not mangled. * Any overridden functions in non-`external` classes inheriting from `external` classes are not mangled. The parameter of `@JsName` is required to be a constant string literal which is a valid identifier. The compiler will report an error on any attempt to pass non-identifier string to `@JsName`. The following example produces a compile-time error: ``` @JsName("new C()") // error here external fun newC() ``` ### @JsExport annotation By applying the `@JsExport` annotation to a top-level declaration (like a class or function), you make the Kotlin declaration available from JavaScript. The annotation exports all nested declarations with the name given in Kotlin. It can also be applied on file-level using `@file:JsExport`. To resolve ambiguities in exports (like overloads for functions with the same name), you can use the `@JsExport` annotation together with `@JsName` to specify the names for the generated and exported functions. The `@JsExport` annotation is available in the current default compiler backend and the new [IR compiler backend](js-ir-compiler). If you are targeting the IR compiler backend, you **must** use the `@JsExport` annotation to make your functions visible from Kotlin in the first place. For multiplatform projects, `@JsExport` is available in common code as well. It only has an effect when compiling for the JavaScript target, and allows you to also export Kotlin declarations that are not platform specific. Kotlin types in JavaScript -------------------------- * Kotlin numeric types, except for `kotlin.Long` are mapped to JavaScript `Number`. * `kotlin.Char` is mapped to JavaScript `Number` representing character code. * Kotlin can't distinguish between numeric types at run time (except for `kotlin.Long`), so the following code works: ``` fun f() { val x: Int = 23 val y: Any = x println(y as Float) } ``` * Kotlin preserves overflow semantics for `kotlin.Int`, `kotlin.Byte`, `kotlin.Short`, `kotlin.Char` and `kotlin.Long`. * `kotlin.Long` is not mapped to any JavaScript object, as there is no 64-bit integer number type in JavaScript. It is emulated by a Kotlin class. * `kotlin.String` is mapped to JavaScript `String`. * `kotlin.Any` is mapped to JavaScript `Object` (`new Object()`, `{}`, and so on). * `kotlin.Array` is mapped to JavaScript `Array`. * Kotlin collections (`List`, `Set`, `Map`, and so on) are not mapped to any specific JavaScript type. * `kotlin.Throwable` is mapped to JavaScript Error. * Kotlin preserves lazy object initialization in JavaScript. * Kotlin does not implement lazy initialization of top-level properties in JavaScript. ### Primitive arrays Primitive array translation utilizes JavaScript `TypedArray`: * `kotlin.ByteArray`, `-.ShortArray`, `-.IntArray`, `-.FloatArray`, and `-.DoubleArray` are mapped to JavaScript `Int8Array`, `Int16Array`, `Int32Array`, `Float32Array`, and `Float64Array` correspondingly. * `kotlin.BooleanArray` is mapped to JavaScript `Int8Array` with a property `$type$ == "BooleanArray"`. * `kotlin.CharArray` is mapped to JavaScript `UInt16Array` with a property `$type$ == "CharArray"`. * `kotlin.LongArray` is mapped to JavaScript `Array` of `kotlin.Long` with a property `$type$ == "LongArray"`. Last modified: 10 January 2023 [Use dependencies from npm](using-packages-from-npm) [JavaScript modules](js-modules) kotlin Kotlin compiler options Kotlin compiler options ======================= Each release of Kotlin includes compilers for the supported targets: JVM, JavaScript, and native binaries for [supported platforms](native-overview#target-platforms). These compilers are used by: * The IDE, when you click the **Compile** or **Run** button for your Kotlin project. * Gradle, when you call `gradle build` in a console or in the IDE. * Maven, when you call `mvn compile` or `mvn test-compile` in a console or in the IDE. You can also run Kotlin compilers manually from the command line as described in the [Working with command-line compiler](command-line) tutorial. Compiler options ---------------- Kotlin compilers have a number of options for tailoring the compiling process. Compiler options for different targets are listed on this page together with a description of each one. There are several ways to set the compiler options and their values (*compiler arguments*): * In IntelliJ IDEA, write in the compiler arguments in the **Additional command line parameters** text box in **Settings/Preferences** | **Build, Execution, Deployment** | **Compiler** | **Kotlin Compiler**. * If you're using Gradle, specify the compiler arguments in the `compilerOptions` property of the Kotlin compilation task. For details, see [Gradle compiler options](gradle-compiler-options#how-to-define-options). * If you're using Maven, specify the compiler arguments in the `<configuration>` element of the Maven plugin node. For details, see [Maven](maven#specifying-compiler-options). * If you run a command-line compiler, add the compiler arguments directly to the utility call or write them into an [argfile](#argfile). For example: ``` $ kotlinc hello.kt -include-runtime -d hello.jar ``` Common options -------------- The following options are common for all Kotlin compilers. ### -version Display the compiler version. ### -nowarn Suppress the compiler from displaying warnings during compilation. ### -Werror Turn any warnings into a compilation error. ### -verbose Enable verbose logging output which includes details of the compilation process. ### -script Evaluate a Kotlin script file. When called with this option, the compiler executes the first Kotlin script (`*.kts`) file among the given arguments. ### -help (-h) Display usage information and exit. Only standard options are shown. To show advanced options, use `-X`. ### -X Display information about the advanced options and exit. These options are currently unstable: their names and behavior may be changed without notice. ### -kotlin-home path Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries. ### -P plugin:pluginId:optionName=value Pass an option to a Kotlin compiler plugin. Available plugins and their options are listed in the **Tools > Compiler plugins** section of the documentation. ### -language-version version Provide source compatibility with the specified version of Kotlin. ### -api-version version Allow using declarations only from the specified version of Kotlin bundled libraries. ### -progressive Enable the [progressive mode](whatsnew13#progressive-mode) for the compiler. In the progressive mode, deprecations and bug fixes for unstable code take effect immediately, instead of going through a graceful migration cycle. Code written in the progressive mode is backwards compatible; however, code written in a non-progressive mode may cause compilation errors in the progressive mode. ### @argfile Read the compiler options from the given file. Such a file can contain compiler options with values and paths to the source files. Options and paths should be separated by whitespaces. For example: `-include-runtime -d hello.jar hello.kt` To pass values that contain whitespaces, surround them with single (**'**) or double (**"**) quotes. If a value contains quotation marks in it, escape them with a backslash (**\**). `-include-runtime -d 'My folder'` You can also pass multiple argument files, for example, to separate compiler options from source files. ``` $ kotlinc @compiler.options @classes ``` If the files reside in locations different from the current directory, use relative paths. ``` $ kotlinc @options/compiler.options hello.kt ``` ### -opt-in annotation Enable usages of API that [requires opt-in](opt-in-requirements) with a requirement annotation with the given fully qualified name. Kotlin/JVM compiler options --------------------------- The Kotlin compiler for JVM compiles Kotlin source files into Java class files. The command-line tools for Kotlin to JVM compilation are `kotlinc` and `kotlinc-jvm`. You can also use them for executing Kotlin script files. In addition to the [common options](#common-options), Kotlin/JVM compiler has the options listed below. ### -classpath path (-cp path) Search for class files in the specified paths. Separate elements of the classpath with system path separators (**;** on Windows, **:** on macOS/Linux). The classpath can contain file and directory paths, ZIP, or JAR files. ### -d path Place the generated class files into the specified location. The location can be a directory, a ZIP, or a JAR file. ### -include-runtime Include the Kotlin runtime into the resulting JAR file. Makes the resulting archive runnable on any Java-enabled environment. ### -jdk-home path Use a custom JDK home directory to include into the classpath if it differs from the default `JAVA_HOME`. ### -Xjdk-release=version Specify the target version of the generated JVM bytecode. Limit the API of the JDK in the classpath to the specified Java version. Automatically sets [`-jvm-target version`](#jvm-target-version). Possible values are `1.8`, `9`, `10`, ..., `19`. The default value is `1.8`. ### -jvm-target version Specify the target version of the generated JVM bytecode. Possible values are `1.8`, `9`, `10`, ..., `19`. The default value is `1.8`. ### -java-parameters Generate metadata for Java 1.8 reflection on method parameters. ### -module-name name (JVM) Set a custom name for the generated `.kotlin_module` file. ### -no-jdk Don't automatically include the Java runtime into the classpath. ### -no-reflect Don't automatically include the Kotlin reflection (`kotlin-reflect.jar`) into the classpath. ### -no-stdlib (JVM) Don't automatically include the Kotlin/JVM stdlib (`kotlin-stdlib.jar`) and Kotlin reflection (`kotlin-reflect.jar`) into the classpath. ### -script-templates classnames[,] Script definition template classes. Use fully qualified class names and separate them with commas (**,**). Kotlin/JS compiler options -------------------------- The Kotlin compiler for JS compiles Kotlin source files into JavaScript code. The command-line tool for Kotlin to JS compilation is `kotlinc-js`. In addition to the [common options](#common-options), Kotlin/JS compiler has the options listed below. ### -libraries path Paths to Kotlin libraries with `.meta.js` and `.kjsm` files, separated by the system path separator. ### -main {call|noCall} Define whether the `main` function should be called upon execution. ### -meta-info Generate `.meta.js` and `.kjsm` files with metadata. Use this option when creating a JS library. ### -module-kind {umd|commonjs|amd|plain} The kind of JS module generated by the compiler: * `umd` - a [Universal Module Definition](https://github.com/umdjs/umd) module * `commonjs` - a [CommonJS](http://www.commonjs.org/) module * `amd` - an [Asynchronous Module Definition](https://en.wikipedia.org/wiki/Asynchronous_module_definition) module * `plain` - a plain JS module To learn more about the different kinds of JS module and the distinctions between them, see [this](https://www.davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/) article. ### -no-stdlib (JS) Don't automatically include the default Kotlin/JS stdlib into the compilation dependencies. ### -output filepath Set the destination file for the compilation result. The value must be a path to a `.js` file including its name. ### -output-postfix filepath Add the content of the specified file to the end of the output file. ### -output-prefix filepath Add the content of the specified file to the beginning of the output file. ### -source-map Generate the source map. ### -source-map-base-dirs path Use the specified paths as base directories. Base directories are used for calculating relative paths in the source map. ### -source-map-embed-sources {always|never|inlining} Embed source files into the source map. ### -source-map-prefix Add the specified prefix to paths in the source map. Kotlin/Native compiler options ------------------------------ Kotlin/Native compiler compiles Kotlin source files into native binaries for the [supported platforms](native-overview#target-platforms). The command-line tool for Kotlin/Native compilation is `kotlinc-native`. In addition to the [common options](#common-options), Kotlin/Native compiler has the options listed below. ### -enable-assertions (-ea) Enable runtime assertions in the generated code. ### -g Enable emitting debug information. ### -generate-test-runner (-tr) Produce an application for running unit tests from the project. ### -generate-worker-test-runner (-trw) Produce an application for running unit tests in a [worker thread](native-immutability#concurrency-in-kotlin-native). ### -generate-no-exit-test-runner (-trn) Produce an application for running unit tests without an explicit process exit. ### -include-binary path (-ib path) Pack external binary within the generated klib file. ### -library path (-l path) Link with the library. To learn about using libraries in Kotlin/native projects, see [Kotlin/Native libraries](native-libraries). ### -library-version version (-lv version) Set the library version. ### -list-targets List the available hardware targets. ### -manifest path Provide a manifest addend file. ### -module-name name (Native) Specify a name for the compilation module. This option can also be used to specify a name prefix for the declarations exported to Objective-C: [How do I specify a custom Objective-C prefix/name for my Kotlin framework?](native-faq#how-do-i-specify-a-custom-objective-c-prefix-name-for-my-kotlin-framework) ### -native-library path (-nl path) Include the native bitcode library. ### -no-default-libs Disable linking user code with the [default platform libraries](native-platform-libs) distributed with the compiler. ### -nomain Assume the `main` entry point to be provided by external libraries. ### -nopack Don't pack the library into a klib file. ### -linker-option Pass an argument to the linker during binary building. This can be used for linking against some native library. ### -linker-options args Pass multiple arguments to the linker during binary building. Separate arguments with whitespaces. ### -nostdlib Don't link with stdlib. ### -opt Enable compilation optimizations. ### -output name (-o name) Set the name for the output file. ### -entry name (-e name) Specify the qualified entry point name. ### -produce output (-p output) Specify output file kind: * `program` * `static` * `dynamic` * `framework` * `library` * `bitcode` ### -repo path (-r path) Library search path. For more information, see [Library search sequence](native-libraries#library-search-sequence). ### -target target Set hardware target. To see the list of available targets, use the [`-list-targets`](#list-targets) option. Last modified: 10 January 2023 [Kotlin command-line compiler](command-line) [All-open compiler plugin](all-open-plugin)
programming_docs
kotlin Kotlin documentation as PDF Kotlin documentation as PDF =========================== Here you can download a PDF version of Kotlin documentation that includes everything except tutorials and API reference. **[Download Kotlin 1.8.0 documentation (PDF)](kotlin-reference.pdf)** **[View the latest Kotlin documentation (online)](home)** Last modified: 10 January 2023 [Security](security) [Contribution](contribute) kotlin Add dependencies on a Pod library Add dependencies on a Pod library ================================= To add dependencies between a Kotlin project and a Pod library, you should [complete the initial configuration](native-cocoapods#set-up-an-environment-to-work-with-cocoapods). This allows you to add dependencies on different types of Pod libraries. When you add a new dependency and re-import the project in IntelliJ IDEA, the new dependency will be added automatically. No additional steps are required. To use your Kotlin project with Xcode, you should [make changes in your project Podfile](native-cocoapods#update-podfile-for-xcode). A Kotlin project requires the `pod()` function call in `build.gradle(.kts)` for adding a Pod dependency. Each dependency requires its separate function call. You can specify the parameters for the dependency in the configuration block of the function. You can find a sample project [here](https://github.com/Kotlin/kmm-with-cocoapods-sample). From the CocoaPods repository ----------------------------- 1. Specify the name of a Pod library in the `pod()` function. In the configuration block, you can specify the version of the library using the `version` parameter. To use the latest version of the library, you can just omit this parameter altogether. 2. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { ios.deploymentTarget = "13.5" summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" pod("AFNetworking") { version = "~> 4.0.1" } } } ``` 3. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.AFNetworking.* ``` On a locally stored library --------------------------- 1. Specify the name of a Pod library in the `pod()` function. In the configuration block, specify the path to the local Pod library: use the `path()` function in the `source` parameter value. 2. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" pod("pod_dependency") { version = "1.0" source = path(project.file("../pod_dependency")) } pod("subspec_dependency/Core") { version = "1.0" source = path(project.file("../subspec_dependency")) } pod("AFNetworking") { version = "~> 4.0.1" } } } ``` 3. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.pod_dependency.* import cocoapods.subspec_dependency.* import cocoapods.AFNetworking.* ``` From a custom Git repository ---------------------------- 1. Specify the name of a Pod library in the `pod()` function. In the configuration block, specify the path to the git repository: use the `git()` function in the `source` parameter value. Additionally, you can specify the following parameters in the block after `git()`: * `commit` – to use a specific commit from the repository * `tag` – to use a specific tag from the repository * `branch` – to use a specific branch from the repositoryThe `git()` function prioritizes passed parameters in the following order: `commit`, `tag`, `branch`. If you don't specify a parameter, the Kotlin plugin uses `HEAD` from the `master` branch. 2. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" pod("AFNetworking") { source = git("https://github.com/AFNetworking/AFNetworking") { tag = "4.0.0" } } pod("JSONModel") { source = git("https://github.com/jsonmodel/jsonmodel.git") { branch = "key-mapper-class" } } pod("CocoaLumberjack") { source = git("https://github.com/CocoaLumberjack/CocoaLumberjack.git") { commit = "3e7f595e3a459c39b917aacf9856cd2a48c4dbf3" } } } } ``` 3. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.AFNetworking.* import cocoapods.JSONModel.* import cocoapods.CocoaLumberjack.* ``` From a custom Podspec repository -------------------------------- 1. Specify the HTTP address to the custom Podspec repository using the `url()` inside the `specRepos` block. 2. Specify the name of a Pod library in the `pod()` function. 3. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" specRepos { url("https://github.com/Kotlin/kotlin-cocoapods-spec.git") } pod("example") } } ``` 4. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.example.* ``` With custom cinterop options ---------------------------- 1. Specify the name of a Pod library in the `pod()` function. In the configuration block, specify the cinterop options: * `extraOpts` – to specify the list of options for a Pod library. For example, specific flags: `extraOpts = listOf("-compiler-option")` * `packageName` – to specify the package name. If you specify this, you can import the library using the package name: `import <packageName>`. 2. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" useLibraries() pod("YandexMapKit") { packageName = "YandexMK" } } } ``` 3. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.YandexMapKit.* ``` If you use the `packageName` parameter, you can import the library using the package name `import <packageName>`: ``` import YandexMK.YMKPoint import YandexMK.YMKDistance ``` On a static Pod library ----------------------- 1. Specify the name of the library using the `pod()` function. 2. Call the `useLibraries()` function – it enables a special flag for static libraries. 3. Specify the minimum deployment target version for the Pod library. ``` kotlin { ios() cocoapods { summary = "CocoaPods test library" homepage = "https://github.com/JetBrains/kotlin" ios.deploymentTarget = "13.5" pod("YandexMapKit") { version = "~> 3.2" } useLibraries() } } ``` 4. Re-import the project. To use these dependencies from the Kotlin code, import the packages `cocoapods.<library-name>`. ``` import cocoapods.YandexMapKit.* ``` Last modified: 10 January 2023 [CocoaPods overview and setup](native-cocoapods) [Use a Kotlin Gradle project as a CocoaPods dependency](native-cocoapods-xcode) kotlin Kotlin for server side Kotlin for server side ====================== Kotlin is a great fit for developing server-side applications. It allows you to write concise and expressive code while maintaining full compatibility with existing Java-based technology stacks, all with a smooth learning curve: * **Expressiveness**: Kotlin's innovative language features, such as its support for [type-safe builders](type-safe-builders) and [delegated properties](delegated-properties), help build powerful and easy-to-use abstractions. * **Scalability**: Kotlin's support for [coroutines](coroutines-overview) helps build server-side applications that scale to massive numbers of clients with modest hardware requirements. * **Interoperability**: Kotlin is fully compatible with all Java-based frameworks, so you can use your familiar technology stack while reaping the benefits of a more modern language. * **Migration**: Kotlin supports gradual migration of large codebases from Java to Kotlin. You can start writing new code in Kotlin while keeping older parts of your system in Java. * **Tooling**: In addition to great IDE support in general, Kotlin offers framework-specific tooling (for example, for Spring) in the plugin for IntelliJ IDEA Ultimate. * **Learning Curve**: For a Java developer, getting started with Kotlin is very easy. The automated Java-to-Kotlin converter included in the Kotlin plugin helps with the first steps. [Kotlin Koans](koans) can guide you through the key features of the language with a series of interactive exercises. Frameworks for server-side development with Kotlin -------------------------------------------------- * [Spring](https://spring.io) makes use of Kotlin's language features to offer [more concise APIs](https://spring.io/blog/2017/01/04/introducing-kotlin-support-in-spring-framework-5-0), starting with version 5.0. The [online project generator](https://start.spring.io/#!language=kotlin) allows you to quickly generate a new project in Kotlin. * [Vert.x](https://vertx.io), a framework for building reactive Web applications on the JVM, offers [dedicated support](https://github.com/vert-x3/vertx-lang-kotlin) for Kotlin, including [full documentation](https://vertx.io/docs/vertx-core/kotlin/). * [Ktor](https://github.com/kotlin/ktor) is a framework built by JetBrains for creating Web applications in Kotlin, making use of coroutines for high scalability and offering an easy-to-use and idiomatic API. * [kotlinx.html](https://github.com/kotlin/kotlinx.html) is a DSL that can be used to build HTML in Web applications. It serves as an alternative to traditional templating systems such as JSP and FreeMarker. * [Micronaut](https://micronaut.io/) is a modern JVM-based full-stack framework for building modular, easily testable microservices and serverless applications. It comes with a lot of useful built-in features. * [http4k](https://http4k.org/) is the functional toolkit with a tiny footprint for Kotlin HTTP applications, written in pure Kotlin. The library is based on the "Your Server as a Function" paper from Twitter and represents modeling both HTTP servers and clients as simple Kotlin functions that can be composed together. * [Javalin](https://javalin.io) is a very lightweight web framework for Kotlin and Java which supports WebSockets, HTTP2, and async requests. * The available options for persistence include direct JDBC access, JPA, and using NoSQL databases through their Java drivers. For JPA, the [kotlin-jpa compiler plugin](no-arg-plugin#jpa-support) adapts Kotlin-compiled classes to the requirements of the framework. Deploying Kotlin server-side applications ----------------------------------------- Kotlin applications can be deployed into any host that supports Java Web applications, including Amazon Web Services, Google Cloud Platform, and more. To deploy Kotlin applications on [Heroku](https://www.heroku.com), you can follow the [official Heroku tutorial](https://devcenter.heroku.com/articles/getting-started-with-kotlin). AWS Labs provides a [sample project](https://github.com/awslabs/serverless-photo-recognition) showing the use of Kotlin for writing [AWS Lambda](https://aws.amazon.com/lambda/) functions. Google Cloud Platform offers a series of tutorials for deploying Kotlin applications to GCP, both for [Ktor and App Engine](https://cloud.google.com/community/tutorials/kotlin-ktor-app-engine-java8) and [Spring and App engine](https://cloud.google.com/community/tutorials/kotlin-springboot-app-engine-java8). In addition, there is an [interactive code lab](https://codelabs.developers.google.com/codelabs/cloud-spring-cloud-gcp-kotlin) for deploying a Kotlin Spring application. Products that use Kotlin on the server side ------------------------------------------- [Corda](https://www.corda.net/) is an open-source distributed ledger platform that is supported by major banks and built entirely in Kotlin. [JetBrains Account](https://account.jetbrains.com/), the system responsible for the entire license sales and validation process at JetBrains, is written in 100% Kotlin and has been running in production since 2015 with no major issues. Next steps ---------- * For a more in-depth introduction to the language, check out the Kotlin documentation on this site and [Kotlin Koans](koans). * Watch a webinar ["Micronaut for microservices with Kotlin"](https://micronaut.io/2020/12/03/webinar-micronaut-for-microservices-with-kotlin/) and explore a detailed [guide](https://guides.micronaut.io/latest/micronaut-kotlin-extension-fns.html) showing how you can use [Kotlin extension functions](extensions#extension-functions) in the Micronaut framework. * http4k provides the [CLI](https://toolbox.http4k.org) to generate fully formed projects, and a [starter](https://start.http4k.org) repo to generate an entire CD pipeline using GitHub, Travis, and Heroku with a single bash command. * Want to migrate from Java to Kotlin? Learn how to perform [typical tasks with strings in Java and Kotlin](java-to-kotlin-idioms-strings). Last modified: 10 January 2023 [Kotlin Multiplatform](multiplatform) [Kotlin for Android](android-overview) kotlin What's new in Kotlin 1.8.0 What's new in Kotlin 1.8.0 ========================== *[Release date: 28 December 2022](releases#release-details)* The Kotlin 1.8.0 release is out and here are some of its biggest highlights: * [New experimental functions for JVM: recursively copy or delete directory content](#recursive-copying-or-deletion-of-directories) * [Improved kotlin-reflect performance](#improved-kotlin-reflect-performance) * [New -Xdebug compiler option for better debugging experience](#a-new-compiler-option-for-disabling-optimizations) * [`kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` merged into `kotlin-stdlib`](#updated-jvm-compilation-target) * [Improved Objective-C/Swift interoperability](#improved-objective-c-swift-interoperability) * [Compatibility with Gradle 7.3](#gradle) IDE support ----------- The Kotlin plugin that supports 1.8.0 is available for: | IDE | Supported versions | | --- | --- | | IntelliJ IDEA | 2021.3, 2022.1, 2022.2 | | Android Studio | Electric Eel (221), Flamingo (222) | Kotlin/JVM ---------- Starting with version 1.8.0, the compiler can generate classes with a bytecode version corresponding to JVM 19. The new language version also includes: * [A compiler option for switching off the generation of JVM annotation targets](#ability-to-not-generate-type-use-and-type-parameter-annotation-targets) * [A new `-Xdebug` compiler option for disabling optimizations](#a-new-compiler-option-for-disabling-optimizations) * [The removal of the old backend](#removal-of-the-old-backend) * [Support for Lombok's @Builder annotation](#support-for-lombok-s-builder-annotation) ### Ability to not generate TYPE\_USE and TYPE\_PARAMETER annotation targets If a Kotlin annotation has `TYPE` among its Kotlin targets, the annotation maps to `java.lang.annotation.ElementType.TYPE_USE` in its list of Java annotation targets. This is just like how the `TYPE_PARAMETER` Kotlin target maps to the `java.lang.annotation.ElementType.TYPE_PARAMETER` Java target. This is an issue for Android clients with API levels less than 26, which don't have these targets in the API. Starting with Kotlin 1.8.0, you can use the new compiler option `-Xno-new-java-annotation-targets` to avoid generating the `TYPE_USE` and `TYPE_PARAMETER` annotation targets. ### A new compiler option for disabling optimizations Kotlin 1.8.0 adds a new `-Xdebug` compiler option, which disables optimizations for a better debugging experience. For now, the option disables the "was optimized out" feature for coroutines. In the future, after we add more optimizations, this option will disable them, too. The "was optimized out" feature optimizes variables when you use suspend functions. However, it is difficult to debug code with optimized variables because you don't see their values. ### Removal of the old backend In Kotlin 1.5.0, we [announced](whatsnew15#stable-jvm-ir-backend) that the IR-based backend became [Stable](components-stability). That meant that the old backend from Kotlin 1.4.\* was deprecated. In Kotlin 1.8.0, we've removed the old backend completely. By extension, we've removed the compiler option `-Xuse-old-backend` and the Gradle `useOldBackend` option. ### Support for Lombok's @Builder annotation The community has added so many votes for the [Kotlin Lombok: Support generated builders (@Builder)](https://youtrack.jetbrains.com/issue/KT-46959) YouTrack issue that we just had to support the [@Builder annotation](https://projectlombok.org/features/Builder). We don't yet have plans to support the `@SuperBuilder` or `@Tolerate` annotations, but we'll reconsider if enough people vote for the [@SuperBuilder](https://youtrack.jetbrains.com/issue/KT-53563/Kotlin-Lombok-Support-SuperBuilder) and [@Tolerate](https://youtrack.jetbrains.com/issue/KT-53564/Kotlin-Lombok-Support-Tolerate) issues. [Learn how to configure the Lombok compiler plugin](lombok#gradle). Kotlin/Native ------------- Kotlin 1.8.0 includes changes to Objective-C and Swift interoperability, support for Xcode 14.1, and improvements to the CocoaPods Gradle plugin: * [Support for Xcode 14.1](#support-for-xcode-14-1) * [Improved Objective-C/Swift interoperability](#improved-objective-c-swift-interoperability) * [Dynamic frameworks by default in the CocoaPods Gradle plugin](#dynamic-frameworks-by-default-in-the-cocoapods-gradle-plugin) ### Support for Xcode 14.1 The Kotlin/Native compiler now supports the latest stable Xcode version, 14.1. The compatibility improvements include the following changes: * There's a new `watchosDeviceArm64` preset for the watchOS target that supports Apple watchOS on ARM64 platforms. * The Kotlin CocoaPods Gradle plugin no longer has bitcode embedding for Apple frameworks by default. * Platform libraries were updated to reflect the changes to Objective-C frameworks for Apple targets. ### Improved Objective-C/Swift interoperability To make Kotlin more interoperable with Objective-C and Swift, three new annotations were added: * [`@ObjCName`](../api/latest/jvm/stdlib/kotlin.native/-obj-c-name/index) allows you to specify a more idiomatic name in Swift or Objective-C, instead of renaming the Kotlin declaration. The annotation instructs the Kotlin compiler to use a custom Objective-C and Swift name for this class, property, parameter, or function: ``` @ObjCName(swiftName = "MySwiftArray") class MyKotlinArray { @ObjCName("index") fun indexOf(@ObjCName("of") element: String): Int = TODO() } // Usage with the ObjCName annotations let array = MySwiftArray() let index = array.index(of: "element") ``` * [`@HiddenFromObjC`](../api/latest/jvm/stdlib/kotlin.native/-hidden-from-obj-c/index) allows you to hide a Kotlin declaration from Objective-C. The annotation instructs the Kotlin compiler not to export a function or property to Objective-C and, consequently, Swift. This can make your Kotlin code more Objective-C/Swift-friendly. * [`@ShouldRefineInSwift`](../api/latest/jvm/stdlib/kotlin.native/-should-refine-in-swift/index) is useful for replacing a Kotlin declaration with a wrapper written in Swift. The annotation instructs the Kotlin compiler to mark a function or property as `swift_private` in the generated Objective-C API. Such declarations get the `__` prefix, which makes them invisible to Swift code. You can still use these declarations in your Swift code to create a Swift-friendly API, but they won't be suggested by Xcode's autocompletion, for example. For more information on refining Objective-C declarations in Swift, see the [official Apple documentation](https://developer.apple.com/documentation/swift/improving-objective-c-api-declarations-for-swift). The Kotlin team is very grateful to [Rick Clephas](https://github.com/rickclephas) for implementing these annotations. ### Dynamic frameworks by default in the CocoaPods Gradle plugin Starting with Kotlin 1.8.0, Kotlin frameworks registered by the CocoaPods Gradle plugin are linked dynamically by default. The previous static implementation was inconsistent with the behavior of the Kotlin Gradle plugin. ``` kotlin { cocoapods { framework { baseName = "MyFramework" isStatic = false // Now dynamic by default } } } ``` If you have an existing project with a static linking type and you upgrade to Kotlin 1.8.0 (or change the linking type explicitly), you may encounter an error with the project's execution. To fix it, close your Xcode project and run `pod install` in the Podfile directory. For more information, see the [CocoaPods Gradle plugin DSL reference](native-cocoapods-dsl-reference). Kotlin Multiplatform: A new Android source set layout ----------------------------------------------------- Kotlin 1.8.0 introduces a new Android source set layout that replaces the previous naming schema for directories, which is confusing in multiple ways. Consider an example of two `androidTest` directories created in the current layout. One is for `KotlinSourceSets` and the other is for `AndroidSourceSets`: * They have different semantics: Kotlin's `androidTest` belongs to the `unitTest` type, whereas Android's belongs to the `integrationTest` type. * They create a confusing `SourceDirectories` layout, as `src/androidTest/java` has a `UnitTest` and `src/androidTest/kotlin` has an `InstrumentedTest`. * Both `KotlinSourceSets` and `AndroidSourceSets` use a similar naming schema for Gradle configurations, so the resulting configurations of `androidTest` for both Kotlin's and Android's source sets are the same: `androidTestImplementation`, `androidTestApi`, `androidTestRuntimeOnly`, and `androidTestCompileOnly`. To address these and other existing issues, we've introduced a new Android source set layout. Here are some of the key differences between the two layouts: ### KotlinSourceSet naming schema | Current source set layout | New source set layout | | --- | --- | | `targetName` + `AndroidSourceSet.name` | `targetName` + `AndroidVariantType` | `{AndroidSourceSet.name}` maps to `{KotlinSourceSet.name}` as follows: | | Current source set layout | New source set layout | | --- | --- | --- | | main | androidMain | androidMain | | test | androidTest | android**Unit**Test | | androidTest | android**Android**Test | android**Instrumented**Test | ### SourceDirectories | Current source set layout | New source set layout | | --- | --- | | The layout adds additional `/kotlin` SourceDirectories | `src/{AndroidSourceSet.name}/kotlin`, `src/{KotlinSourceSet.name}/kotlin` | `{AndroidSourceSet.name}` maps to `{SourceDirectories included}` as follows: | | Current source set layout | New source set layout | | --- | --- | --- | | main | src/androidMain/kotlin, src/main/kotlin, src/main/java | src/androidMain/kotlin, src/main/kotlin, src/main/java | | test | src/androidTest/kotlin, src/test/kotlin, src/test/java | src/android**Unit**Test/kotlin, src/test/kotlin, src/test/java | | androidTest | src/android**Android**Test/kotlin, src/androidTest/java | src/android**Instrumented**Test/kotlin, src/androidTest/java, **src/androidTest/kotlin** | ### The location of the AndroidManifest.xml file | Current source set layout | New source set layout | | --- | --- | | src/{**Android**SourceSet.name}/AndroidManifest.xml | src/{**Kotlin**SourceSet.name}/AndroidManifest.xml | `{AndroidSourceSet.name}` maps to`{AndroidManifest.xml location}` as follows: | | Current source set layout | New source set layout | | --- | --- | --- | | main | src/main/AndroidManifest.xml | src/**android**Main/AndroidManifest.xml | | debug | src/debug/AndroidManifest.xml | src/**android**Debug/AndroidManifest.xml | ### Configuration and setup The new layout will become the default in future releases. You can enable it now with the following Gradle option: ``` kotlin.mpp.androidSourceSetLayoutVersion=2 ``` The usage of the previous Android-style directories is now discouraged. Kotlin 1.8.0 marks the start of the deprecation cycle, introducing a warning for the current layout. You can suppress the warning with the following Gradle property: ``` kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true ``` Kotlin/JS --------- Kotlin 1.8.0 stabilizes the JS IR compiler backend and brings new features to JavaScript-related Gradle build scripts: * [Stable JS IR compiler backend](#stable-js-ir-compiler-backend) * [New settings for reporting that yarn.lock has been updated](#new-settings-for-reporting-that-yarn-lock-has-been-updated) * [Add test targets for browsers via Gradle properties](#add-test-targets-for-browsers-via-gradle-properties) * [New approach to adding CSS support to your project](#new-approach-to-adding-css-support-to-your-project) ### Stable JS IR compiler backend Starting with this release, the [Kotlin/JS intermediate representation (IR-based) compiler](js-ir-compiler) backend is Stable. It took a while to unify infrastructure for all three backends, but they now work with the same IR for Kotlin code. As a consequence of the stable JS IR compiler backend, the old one is deprecated from now on. Incremental compilation is enabled by default along with the stable JS IR compiler. If you still use the old compiler, switch your project to the new backend with the help of our [migration guide](js-ir-migration). ### New settings for reporting that yarn.lock has been updated If you use the `yarn` package manager, there are three new special Gradle settings that could notify you if the `yarn.lock` file has been updated. You can use these settings when you want to be notified if `yarn.lock` has been changed silently during the CI build process. These three new Gradle properties are: * `YarnLockMismatchReport`, which specifies how changes to the `yarn.lock` file are reported. You can use one of the following values: + `FAIL` fails the corresponding Gradle task. This is the default. + `WARNING` writes the information about changes in the warning log. + `NONE` disables reporting. * `reportNewYarnLock`, which reports about the recently created `yarn.lock` file explicitly. By default, this option is disabled: it's a common practice to generate a new `yarn.lock` file at the first start. You can use this option to ensure that the file has been committed to your repository. * `yarnLockAutoReplace`, which replaces `yarn.lock` automatically every time the Gradle task is run. To use these options, update your build script file `build.gradle.kts` as follows: ``` import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension rootProject.plugins.withType(org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin::class.java) { rootProject.the<YarnRootExtension>().yarnLockMismatchReport = YarnLockMismatchReport.WARNING // NONE | FAIL rootProject.the<YarnRootExtension>().reportNewYarnLock = false // true rootProject.the<YarnRootExtension>().yarnLockAutoReplace = false // true } ``` ### Add test targets for browsers via Gradle properties Starting with Kotlin 1.8.0, you can set test targets for different browsers right in the Gradle properties file. Doing so shrinks the size of the build script file as you no longer need to write all targets in `build.gradle.kts`. You can use this property to define a list of browsers for all modules, and then add specific browsers in the build scripts of particular modules. For example, the following line in your Gradle property file will run the test in Firefox and Safari for all modules: ``` kotlin.js.browser.karma.browsers=firefox,safari ``` See the full list of [available values for the property on GitHub](https://github.com/JetBrains/kotlin/blob/master/libraries/tools/kotlin-gradle-plugin/src/common/kotlin/org/jetbrains/kotlin/gradle/targets/js/testing/karma/KotlinKarma.kt#L106). The Kotlin team is very grateful to [Martynas Petuška](https://github.com/mpetuska) for implementing this feature. ### New approach to adding CSS support to your project This release provides a new approach to adding CSS support to your project. We assume that this will affect a lot of projects, so don't forget to update your Gradle build script files as described below. Before Kotlin 1.8.0, the `cssSupport.enabled` property was used to add CSS support: ``` cssSupport.enabled = true ``` Now you should use the `enabled.set()` method in the `cssSupport{}` block: ``` cssSupport { enabled.set(true) } ``` Gradle ------ Kotlin 1.8.0 **fully** supports Gradle versions 7.2 and 7.3. You can also use Gradle versions up to the latest Gradle release, but if you do, keep in mind that you might encounter deprecation warnings or some new Gradle features might not work. This version brings lots of changes: * [Exposing Kotlin compiler options as Gradle lazy properties](#exposing-kotlin-compiler-options-as-gradle-lazy-properties) * [Bumping the minimum supported versions](#bumping-the-minimum-supported-versions) * [Ability to disable the Kotlin daemon fallback strategy](#ability-to-disable-the-kotlin-daemon-fallback-strategy) * [Usage of the latest kotlin-stdlib version in transitive dependencies](#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies) * [Obligatory check for JVM target compatibility equality of related Kotlin and Java compile tasks](#obligatory-check-for-jvm-targets-of-related-kotlin-and-java-compile-tasks) * [Resolution of Kotlin Gradle plugins' transitive dependencies](#resolution-of-kotlin-gradle-plugins-transitive-dependencies) * [Deprecations and removals](#deprecations-and-removals) ### Exposing Kotlin compiler options as Gradle lazy properties To expose available Kotlin compiler options as [Gradle lazy properties](https://docs.gradle.org/current/userguide/lazy_configuration.html) and to integrate them better into the Kotlin tasks, we made lots of changes: * Compile tasks have the new `compilerOptions` input, which is similar to the existing `kotlinOptions` but uses [`Property`](https://docs.gradle.org/current/javadoc/org/gradle/api/provider/Property.html) from the Gradle Properties API as the return type: ``` tasks.named("compileKotlin", org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile::class.java) { compilerOptions { useK2.set(true) } } ``` * The Kotlin tools tasks `KotlinJsDce` and `KotlinNativeLink` have the new `toolOptions` input, which is similar to the existing `kotlinOptions` input. * New inputs have the [`@Nested` Gradle annotation](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/Nested.html). Every property inside the inputs has a related Gradle annotation, such as [`@Input` or `@Internal`](https://docs.gradle.org/current/userguide/more_about_tasks.html#sec:up_to_date_checks). * The Kotlin Gradle plugin API artifact has two new interfaces: + `org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask`, which has the `compilerOptions` input and the `compileOptions()` method. All Kotlin compilation tasks implement this interface. + `org.jetbrains.kotlin.gradle.tasks.KotlinToolTask`, which has the `toolOptions` input and the `toolOptions()` method. All Kotlin tool tasks – `KotlinJsDce`, `KotlinNativeLink`, and `KotlinNativeLinkArtifactTask` – implement this interface. * Some `compilerOptions` use the new types instead of the `String` type: + [`JvmTarget`](https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compiler-types/src/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/JvmTarget.kt) + [`KotlinVersion`](https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compiler-types/src/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/KotlinVersion.kt) (for the `apiVersion` and the `languageVersion` inputs) + [`JsMainFunctionExecutionMode`](https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compiler-types/src/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/JsMainFunctionExecutionMode.kt) + [`JsModuleKind`](https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compiler-types/src/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/JsModuleKind.kt) + [`JsSourceMapEmbedMode`](https://github.com/JetBrains/kotlin/blob/1.8.0/libraries/tools/kotlin-gradle-compiler-types/src/generated/kotlin/org/jetbrains/kotlin/gradle/dsl/JsSourceMapEmbedMode.kt)For example, you can use `compilerOptions.jvmTarget.set(JvmTarget.JVM_11)` instead of `kotlinOptions.jvmTarget = "11"`. The `kotlinOptions` types didn't change, and they are internally converted to `compilerOptions` types. * The Kotlin Gradle plugin API is binary-compatible with previous releases. There are, however, some source and ABI-breaking changes in the `kotlin-gradle-plugin` artifact. Most of these changes involve additional generic parameters to some internal types. One important change is that the `KotlinNativeLink` task no longer inherits the `AbstractKotlinNativeCompile` task. * `KotlinJsCompilerOptions.outputFile` and the related `KotlinJsOptions.outputFile` options are deprecated. Use the `Kotlin2JsCompile.outputFileProperty` task input instead. #### Limitations Calling any setter or getter on `kotlinOptions` delegates to the related property in the `compilerOptions`. This introduces the following limitations: * `compilerOptions` and `kotlinOptions` cannot be changed in the task execution phase (see one exception in the paragraph below). * `freeCompilerArgs` returns an immutable `List<String>`, which means that, for example, `kotlinOptions.freeCompilerArgs.remove("something")` will fail. Several plugins, including `kotlin-dsl` and the Android Gradle plugin (AGP) with [Jetpack Compose](https://developer.android.com/jetpack/compose) enabled, try to modify the `freeCompilerArgs` attribute in the task execution phase. We've added a workaround for them in Kotlin 1.8.0. This workaround allows any build script or plugin to modify `kotlinOptions.freeCompilerArgs` in the execution phase but produces a warning in the build log. To disable this warning, use the new Gradle property `kotlin.options.suppressFreeCompilerArgsModificationWarning=true`. Gradle is going to add fixes for the [`kotlin-dsl` plugin](https://github.com/gradle/gradle/issues/22091) and [AGP with Jetpack Compose enabled](https://issuetracker.google.com/u/1/issues/247544167). ### Bumping the minimum supported versions Starting with Kotlin 1.8.0, the minimum supported Gradle version is 6.8.3 and the minimum supported Android Gradle plugin version is 4.1.3. See the [Kotlin Gradle plugin compatibility with available Gradle versions in our documentation](gradle-configure-project#apply-the-plugin) ### Ability to disable the Kotlin daemon fallback strategy There is a new Gradle property `kotlin.daemon.useFallbackStrategy`, whose default value is `true`. When the value is `false`, builds fail on problems with the daemon's startup or communication. There is also a new `useDaemonFallbackStrategy` property in Kotlin compile tasks, which takes priority over the Gradle property if you use both. If there is insufficient memory to run the compilation, you can see a message about it in the logs. The Kotlin compiler's fallback strategy is to run a compilation outside the Kotlin daemon if the daemon somehow fails. If the Gradle daemon is on, the compiler uses the "In process" strategy. If the Gradle daemon is off, the compiler uses the "Out of process" strategy. Learn more about these [execution strategies in the documentation](gradle-compilation-and-caches#defining-kotlin-compiler-execution-strategy). Note that silent fallback to another strategy can consume a lot of system resources or lead to non-deterministic builds; see this [YouTrack issue](https://youtrack.jetbrains.com/issue/KT-48843/Add-ability-to-disable-Kotlin-daemon-fallback-strategy) for more details. ### Usage of the latest kotlin-stdlib version in transitive dependencies If you explicitly write Kotlin version 1.8.0 or higher in your dependencies, for example: `implementation("org.jetbrains.kotlin:kotlin-stdlib:1.8.0")`, then the Kotlin Gradle Plugin will use that Kotlin version for transitive `kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` dependencies. This is done to avoid class duplication from different stdlib versions (learn more about [merging `kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` into `kotlin-stdlib`](#updated-jvm-compilation-target)). You can disable this behavior with the `kotlin.stdlib.jdk.variants.version.alignment` Gradle property: ``` kotlin.stdlib.jdk.variants.version.alignment=false ``` If you run into issues with version alignment, align all versions via the Kotlin [BOM](https://docs.gradle.org/current/userguide/platforms.html#sub:bom_import) by declaring a platform dependency on `kotlin-bom` in your build script: ``` implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0")) ``` Learn about other cases and our suggested solutions in [the documentation](gradle-configure-project#other-ways-to-align-versions). ### Obligatory check for JVM targets of related Kotlin and Java compile tasks [Starting from this release](https://youtrack.jetbrains.com/issue/KT-54993/Raise-kotlin.jvm.target.validation.mode-check-default-level-to-error-when-build-is-running-on-Gradle-8), the default value for the [`kotlin.jvm.target.validation.mode` property](gradle-configure-project#check-for-jvm-target-compatibility-of-related-compile-tasks) is `error` for projects on Gradle 8.0+ (this version of Gradle has not been released yet), and the plugin will fail the build in the event of JVM target incompatibility. The shift of the default value from `warning` to `error` is a preparation step for a smooth migration to Gradle 8.0. **We encourage you to set this property to `error`** and [configure a toolchain](gradle-configure-project#gradle-java-toolchains-support) or align JVM versions manually. Learn more about [what can go wrong if you don't check the targets' compatibility](gradle-configure-project#what-can-go-wrong-if-not-checking-targets-compatibility). ### Resolution of Kotlin Gradle plugins' transitive dependencies In Kotlin 1.7.0, we introduced [support for Gradle plugin variants](whatsnew17#support-for-gradle-plugin-variants). Because of these plugin variants, a build classpath can have different versions of the [Kotlin Gradle plugins](https://plugins.gradle.org/u/kotlin) that depend on different versions of some dependency, usually `kotlin-gradle-plugin-api`. This can lead to a resolution problem, and we would like to propose the following workaround, using the `kotlin-dsl` plugin as an example. The `kotlin-dsl` plugin in Gradle 7.6 depends on the `org.jetbrains.kotlin.plugin.sam.with.receiver:1.7.10` plugin, which depends on `kotlin-gradle-plugin-api:1.7.10`. If you add the `org.jetbrains.kotlin.gradle.jvm:1.8.0` plugin, this `kotlin-gradle-plugin-api:1.7.10` transitive dependency may lead to a dependency resolution error because of a mismatch between the versions (`1.8.0` and `1.7.10`) and the variant attributes' [`org.gradle.plugin.api-version`](https://docs.gradle.org/current/javadoc/org/gradle/api/attributes/plugin/GradlePluginApiVersion.html) values. As a workaround, add this [constraint](https://docs.gradle.org/current/userguide/dependency_constraints.html#sec:adding-constraints-transitive-deps) to align the versions. This workaround may be needed until we implement the [Kotlin Gradle Plugin libraries alignment platform](https://youtrack.jetbrains.com/issue/KT-54691/Kotlin-Gradle-Plugin-libraries-alignment-platform), which is in the plans: ``` dependencies { constraints { implementation("org.jetbrains.kotlin:kotlin-sam-with-receiver:1.8.0") } } ``` This constraint forces the `org.jetbrains.kotlin:kotlin-sam-with-receiver:1.8.0` version to be used in the build classpath for transitive dependencies. Learn more about one similar [case in the Gradle issue tracker](https://github.com/gradle/gradle/issues/22510#issuecomment-1292259298). ### Deprecations and removals In Kotlin 1.8.0, the deprecation cycle continues for the following properties and methods: * [In the notes for Kotlin 1.7.0](whatsnew17#changes-in-compile-tasks) that the `KotlinCompile` task still had the deprecated Kotlin property `classpath`, which would be removed in future releases. Now, we've changed the deprecation level to `error` for the `KotlinCompile` task's `classpath` property. All compile tasks use the `libraries` input for a list of libraries required for compilation. * We removed the `kapt.use.worker.api` property that allowed running <kapt> via the Gradle Workers API. By default, [kapt has been using Gradle workers](kapt#running-kapt-tasks-in-parallel) since Kotlin 1.3.70, and we recommend sticking to this method. * In Kotlin 1.7.0, we [announced the start of a deprecation cycle for the `kotlin.compiler.execution.strategy` property](whatsnew17#deprecation-of-the-kotlin-compiler-execution-strategy-system-property). In this release, we removed this property. Learn how to [define a Kotlin compiler execution strategy](gradle-compilation-and-caches#defining-kotlin-compiler-execution-strategy) in other ways. Standard library ---------------- Kotlin 1.8.0: * Updates [JVM compilation target](#updated-jvm-compilation-target). * Stabilizes a number of functions – [TimeUnit conversion between Java and Kotlin](#timeunit-conversion-between-java-and-kotlin), [`cbrt()`](#cbrt), [Java `Optionals` extension functions](#java-optionals-extension-functions). * Provides a [preview for comparable and subtractable `TimeMarks`](#comparable-and-subtractable-timemarks). * Includes [experimental extension functions for `java.nio.file.path`](#recursive-copying-or-deletion-of-directories). * Presents [improved kotlin-reflect performance](#improved-kotlin-reflect-performance). ### Updated JVM compilation target In Kotlin 1.8.0, the standard libraries (`kotlin-stdlib`, `kotlin-reflect`, and `kotlin-script-*`) are compiled with JVM target 1.8. Previously, the standard libraries were compiled with JVM target 1.6. Kotlin 1.8.0 no longer supports JVM targets 1.6 and 1.7. As a result, you no longer need to declare `kotlin-stdlib-jdk7` and `kotlin-stdlib-jdk8` separately in build scripts because the contents of these artifacts have been merged into `kotlin-stdlib`. Note that mixing different versions of stdlib artifacts could lead to class duplication or to missing classes. To avoid that, the Kotlin Gradle plugin can help you [align stdlib versions](#usage-of-the-latest-kotlin-stdlib-version-in-transitive-dependencies). ### cbrt() The `cbrt()` function, which allows you to compute the real cube root of a `double` or `float`, is now Stable. ``` import kotlin.math.* fun main() { val num = 27 val negNum = -num println("The cube root of ${num.toDouble()} is: " + cbrt(num.toDouble())) println("The cube root of ${negNum.toDouble()} is: " + cbrt(negNum.toDouble())) } ``` ### TimeUnit conversion between Java and Kotlin The `toTimeUnit()` and `toDurationUnit()` functions in `kotlin.time` are now Stable. Introduced as Experimental in Kotlin 1.6.0, these functions improve interoperability between Kotlin and Java. You can now easily convert between Java `java.util.concurrent.TimeUnit` and Kotlin `kotlin.time.DurationUnit`. These functions are supported on the JVM only. ``` import kotlin.time.* // For use from Java fun wait(timeout: Long, unit: TimeUnit) { val duration: Duration = timeout.toDuration(unit.toDurationUnit()) ... } ``` ### Comparable and subtractable TimeMarks Before Kotlin 1.8.0, if you wanted to calculate the time difference between multiple `TimeMarks` and **now**, you could only call `elapsedNow()` on one `TimeMark` at a time. This made it difficult to compare the results because the two `elapsedNow()` function calls couldn't be executed at exactly the same time. To solve this, in Kotlin 1.8.0 you can subtract and compare `TimeMarks` from the same time source. Now you can create a new `TimeMark` instance to represent **now** and subtract other `TimeMarks` from it. This way, the results that you collect from these calculations are guaranteed to be relative to each other. ``` import kotlin.time.* fun main() { //sampleStart val timeSource = TimeSource.Monotonic val mark1 = timeSource.markNow() Thread.sleep(500) // Sleep 0.5 seconds val mark2 = timeSource.markNow() // Before 1.8.0 repeat(4) { n -> val elapsed1 = mark1.elapsedNow() val elapsed2 = mark2.elapsedNow() // Difference between elapsed1 and elapsed2 can vary depending // on how much time passes between the two elapsedNow() calls println("Measurement 1.${n + 1}: elapsed1=$elapsed1, " + "elapsed2=$elapsed2, diff=${elapsed1 - elapsed2}") } println() // Since 1.8.0 repeat(4) { n -> val mark3 = timeSource.markNow() val elapsed1 = mark3 - mark1 val elapsed2 = mark3 - mark2 // Now the elapsed times are calculated relative to mark3, // which is a fixed value println("Measurement 2.${n + 1}: elapsed1=$elapsed1, " + "elapsed2=$elapsed2, diff=${elapsed1 - elapsed2}") } // It's also possible to compare time marks with each other // This is true, as mark2 was captured later than mark1 println(mark2 > mark1) //sampleEnd } ``` This new functionality is particularly useful in animation calculations where you want to calculate the difference between, or compare, multiple `TimeMarks` representing different frames. ### Recursive copying or deletion of directories We have introduced two new extension functions for `java.nio.file.Path`, `copyToRecursively()` and `deleteRecursively()`, which allow you to recursively: * Copy a directory and its contents to another destination. * Delete a directory and its contents. These functions can be very useful as part of a backup process. #### Error handling Using `copyToRecursively()`, you can define what should happen if an exception occurs while copying, by overloading the `onError` lambda function: ``` sourceRoot.copyToRecursively(destinationRoot, followLinks = false, onError = { source, target, exception -> logger.logError(exception, "Failed to copy $source to $target") OnErrorResult.TERMINATE }) ``` When you use `deleteRecursively()`, if an exception occurs while deleting a file or folder, then the file or folder is skipped. Once the deletion has completed, `deleteRecursively()` throws an `IOException` containing all the exceptions that occurred as suppressed exceptions. #### File overwrite If `copyToRecursively()` finds that a file already exists in the destination directory, then an exception occurs. If you want to overwrite the file instead, use the overload that has `overwrite` as an argument and set it to `true`: ``` fun setUpEnvironment(projectDirectory: Path, fixtureName: String) { fixturesRoot.resolve(COMMON_FIXTURE_NAME) .copyToRecursively(projectDirectory, followLinks = false) fixturesRoot.resolve(fixtureName) .copyToRecursively(projectDirectory, followLinks = false, overwrite = true) // patches the common fixture } ``` #### Custom copying action To define your own custom logic for copying, use the overload that has `copyAction` as an additional argument. By using `copyAction` you can provide a lambda function, for example, with your preferred actions: ``` sourceRoot.copyToRecursively(destinationRoot, followLinks = false) { source, target -> if (source.name.startsWith(".")) { CopyActionResult.SKIP_SUBTREE } else { source.copyToIgnoringExistingDirectory(target, followLinks = false) CopyActionResult.CONTINUE } } ``` For more information on these extension functions, see [our API reference](../api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/copy-to-recursively). ### Java Optionals extension functions The extension functions that were introduced in [Kotlin 1.7.0](whatsnew17#new-experimental-extension-functions-for-java-optionals) are now Stable. These functions simplify working with Optional classes in Java. They can be used to unwrap and convert `Optional` objects on the JVM, and to make working with Java APIs more concise. For more information, see [What's new in Kotlin 1.7.0](whatsnew17#new-experimental-extension-functions-for-java-optionals). ### Improved kotlin-reflect performance Taking advantage of the fact that `kotlin-reflect` is now compiled with JVM target 1.8, we migrated our internal cache mechanism to Java's `ClassValue`. Previously we only cached `KClass`, but we now also cache `KType` and `KDeclarationContainer`. These changes have led to significant performance improvements when invoking `typeOf()`. Documentation updates --------------------- The Kotlin documentation has received some notable changes: ### Revamped and new pages * [Gradle overview](gradle) – learn how to configure and build a Kotlin project with the Gradle build system, available compiler options, compilation, and caches in the Kotlin Gradle plugin. * [Nullability in Java and Kotlin](java-to-kotlin-nullability-guide) – see the differences between Java's and Kotlin's approaches to handling possibly nullable variables. * [Lincheck guide](lincheck-guide) – learn how to set up and use the Lincheck framework for testing concurrent algorithms on the JVM. ### New and updated tutorials * [Get started with Gradle and Kotlin/JVM](get-started-with-jvm-gradle-project) – create a console application using IntelliJ IDEA and Gradle. * [Create a multiplatform app using Ktor and SQLDelight](multiplatform-mobile-ktor-sqldelight) – create a mobile application for iOS and Android using Kotlin Multiplatform Mobile. * [Get started with Kotlin Multiplatform Mobile](multiplatform-mobile-getting-started) – learn about cross-platform mobile development with Kotlin and create an app that works on both Android and iOS. Install Kotlin 1.8.0 -------------------- [IntelliJ IDEA](https://www.jetbrains.com/idea/download/) 2021.3, 2022.1, and 2022.2 automatically suggest updating the Kotlin plugin to version 1.8.0. IntelliJ IDEA 2022.3 will have the 1.8.0 version of the Kotlin plugin bundled in an upcoming minor update. For Android Studio Electric Eel (221) and Flamingo (222), version 1.8.0 of the Kotlin plugin will be delivered with the upcoming Android Studios updates. The new command-line compiler is available for download on the [GitHub release page](https://github.com/JetBrains/kotlin/releases/tag/v1.8.0). Compatibility guide for Kotlin 1.8.0 ------------------------------------ Kotlin 1.8.0 is a [feature release](kotlin-evolution#feature-releases-and-incremental-releases) and can, therefore, bring changes that are incompatible with your code written for earlier versions of the language. Find the detailed list of these changes in the [Compatibility guide for Kotlin 1.8.0](compatibility-guide-18). Last modified: 10 January 2023 [Kotlin for competitive programming](competitive-programming) [What's new in Kotlin 1.7.20](whatsnew1720)
programming_docs
kotlin Inline functions Inline functions ================ Using [higher-order functions](lambdas) imposes certain runtime penalties: each function is an object, and it captures a closure. A closure is a scope of variables that can be accessed in the body of the function. Memory allocations (both for function objects and classes) and virtual calls introduce runtime overhead. But it appears that in many cases this kind of overhead can be eliminated by inlining the lambda expressions. The functions shown below are good examples of this situation. The `lock()` function could be easily inlined at call-sites. Consider the following case: ``` lock(l) { foo() } ``` Instead of creating a function object for the parameter and generating a call, the compiler could emit the following code: ``` l.lock() try { foo() } finally { l.unlock() } ``` To make the compiler do this, mark the `lock()` function with the `inline` modifier: ``` inline fun <T> lock(lock: Lock, body: () -> T): T { ... } ``` The `inline` modifier affects both the function itself and the lambdas passed to it: all of those will be inlined into the call site. Inlining may cause the generated code to grow. However, if you do it in a reasonable way (avoiding inlining large functions), it will pay off in performance, especially at "megamorphic" call-sites inside loops. noinline -------- If you don't want all of the lambdas passed to an inline function to be inlined, mark some of your function parameters with the `noinline` modifier: ``` inline fun foo(inlined: () -> Unit, noinline notInlined: () -> Unit) { ... } ``` Inlinable lambdas can only be called inside inline functions or passed as inlinable arguments. `noinline` lambdas, however, can be manipulated in any way you like, including being stored in fields or passed around. Non-local returns ----------------- In Kotlin, you can only use a normal, unqualified `return` to exit a named function or an anonymous function. To exit a lambda, use a [label](returns#return-to-labels). A bare `return` is forbidden inside a lambda because a lambda cannot make the enclosing function `return`: ``` fun ordinaryFunction(block: () -> Unit) { println("hi!") } //sampleStart fun foo() { ordinaryFunction { return // ERROR: cannot make `foo` return here } } //sampleEnd fun main() { foo() } ``` But if the function the lambda is passed to is inlined, the return can be inlined, as well. So it is allowed: ``` inline fun inlined(block: () -> Unit) { println("hi!") } //sampleStart fun foo() { inlined { return // OK: the lambda is inlined } } //sampleEnd fun main() { foo() } ``` Such returns (located in a lambda, but exiting the enclosing function) are called *non-local* returns. This sort of construct usually occurs in loops, which inline functions often enclose: ``` fun hasZeros(ints: List<Int>): Boolean { ints.forEach { if (it == 0) return true // returns from hasZeros } return false } ``` Note that some inline functions may call the lambdas passed to them as parameters not directly from the function body, but from another execution context, such as a local object or a nested function. In such cases, non-local control flow is also not allowed in the lambdas. To indicate that the lambda parameter of the inline function cannot use non-local returns, mark the lambda parameter with the `crossinline` modifier: ``` inline fun f(crossinline body: () -> Unit) { val f = object: Runnable { override fun run() = body() } // ... } ``` Reified type parameters ----------------------- Sometimes you need to access a type passed as a parameter: ``` fun <T> TreeNode.findParentOfType(clazz: Class<T>): T? { var p = parent while (p != null && !clazz.isInstance(p)) { p = p.parent } @Suppress("UNCHECKED_CAST") return p as T? } ``` Here, you walk up a tree and use reflection to check whether a node has a certain type. It's all fine, but the call site is not very pretty: ``` treeNode.findParentOfType(MyTreeNode::class.java) ``` A better solution would be to simply pass a type to this function. You can call it as follows: ``` treeNode.findParentOfType<MyTreeNode>() ``` To enable this, inline functions support *reified type parameters*, so you can write something like this: ``` inline fun <reified T> TreeNode.findParentOfType(): T? { var p = parent while (p != null && p !is T) { p = p.parent } return p as T? } ``` The code above qualifies the type parameter with the `reified` modifier to make it accessible inside the function, almost as if it were a normal class. Since the function is inlined, no reflection is needed and normal operators like `!is` and `as` are now available for you to use. Also, you can call the function as shown above: `myTree.findParentOfType<MyTreeNodeType>()`. Though reflection may not be needed in many cases, you can still use it with a reified type parameter: ``` inline fun <reified T> membersOf() = T::class.members fun main(s: Array<String>) { println(membersOf<StringBuilder>().joinToString("\n")) } ``` Normal functions (not marked as inline) cannot have reified parameters. A type that does not have a run-time representation (for example, a non-reified type parameter or a fictitious type like `Nothing`) cannot be used as an argument for a reified type parameter. Inline properties ----------------- The `inline` modifier can be used on accessors of properties that don't have backing fields. You can annotate individual property accessors: ``` val foo: Foo inline get() = Foo() var bar: Bar get() = ... inline set(v) { ... } ``` You can also annotate an entire property, which marks both of its accessors as `inline`: ``` inline var bar: Bar get() = ... set(v) { ... } ``` At the call site, inline accessors are inlined as regular inline functions. Restrictions for public API inline functions -------------------------------------------- When an inline function is `public` or `protected` but is not a part of a `private` or `internal` declaration, it is considered a [module](visibility-modifiers#modules)'s public API. It can be called in other modules and is inlined at such call sites as well. This imposes certain risks of binary incompatibility caused by changes in the module that declares an inline function in case the calling module is not re-compiled after the change. To eliminate the risk of such incompatibility being introduced by a change in a *non*-public API of a module, public API inline functions are not allowed to use non-public-API declarations, i.e. `private` and `internal` declarations and their parts, in their bodies. An `internal` declaration can be annotated with `@PublishedApi`, which allows its use in public API inline functions. When an `internal` inline function is marked as `@PublishedApi`, its body is checked too, as if it were public. Last modified: 10 January 2023 [High-order functions and lambdas](lambdas) [Operator overloading](operator-overloading) kotlin Asynchronous programming techniques Asynchronous programming techniques =================================== For decades, as developers we are confronted with a problem to solve - how to prevent our applications from blocking. Whether we're developing desktop, mobile, or even server-side applications, we want to avoid having the user wait or what's worse cause bottlenecks that would prevent an application from scaling. There have been many approaches to solving this problem, including: * [Threading](#threading) * [Callbacks](#callbacks) * [Futures, promises, and others](#futures-promises-and-others) * [Reactive Extensions](#reactive-extensions) * [Coroutines](#coroutines) Before explaining what coroutines are, let's briefly review some of the other solutions. Threading --------- Threads are by far probably the most well-known approach to avoid applications from blocking. ``` fun postItem(item: Item) { val token = preparePost() val post = submitPost(token, item) processPost(post) } fun preparePost(): Token { // makes a request and consequently blocks the main thread return token } ``` Let's assume in the code above that `preparePost` is a long-running process and consequently would block the user interface. What we can do is launch it in a separate thread. This would then allow us to avoid the UI from blocking. This is a very common technique, but has a series of drawbacks: * Threads aren't cheap. Threads require context switches which are costly. * Threads aren't infinite. The number of threads that can be launched is limited by the underlying operating system. In server-side applications, this could cause a major bottleneck. * Threads aren't always available. Some platforms, such as JavaScript do not even support threads. * Threads aren't easy. Debugging threads, avoiding race conditions are common problems we suffer in multi-threaded programming. Callbacks --------- With callbacks, the idea is to pass one function as a parameter to another function, and have this one invoked once the process has completed. ``` fun postItem(item: Item) { preparePostAsync { token -> submitPostAsync(token, item) { post -> processPost(post) } } } fun preparePostAsync(callback: (Token) -> Unit) { // make request and return immediately // arrange callback to be invoked later } ``` This in principle feels like a much more elegant solution, but once again has several issues: * Difficulty of nested callbacks. Usually a function that is used as a callback, often ends up needing its own callback. This leads to a series of nested callbacks which lead to incomprehensible code. The pattern is often referred to as the titled christmas tree (braces represent branches of the tree). * Error handling is complicated. The nesting model makes error handling and propagation of these somewhat more complicated. Callbacks are quite common in event-loop architectures such as JavaScript, but even there, generally people have moved away to using other approaches such as promises or reactive extensions. Futures, promises, and others ----------------------------- The idea behind futures or promises (there are also other terms these can be referred to depending on language/platform), is that when we make a call, we're promised that at some point it will return with an object called a Promise, which can then be operated on. ``` fun postItem(item: Item) { preparePostAsync() .thenCompose { token -> submitPostAsync(token, item) } .thenAccept { post -> processPost(post) } } fun preparePostAsync(): Promise<Token> { // makes request and returns a promise that is completed later return promise } ``` This approach requires a series of changes in how we program, in particular: * Different programming model. Similar to callbacks, the programming model moves away from a top-down imperative approach to a compositional model with chained calls. Traditional program structures such as loops, exception handling, etc. usually are no longer valid in this model. * Different APIs. Usually there's a need to learn a completely new API such as `thenCompose` or `thenAccept`, which can also vary across platforms. * Specific return type. The return type moves away from the actual data that we need and instead returns a new type `Promise` which has to be introspected. * Error handling can be complicated. The propagation and chaining of errors aren't always straightforward. Reactive extensions ------------------- Reactive Extensions (Rx) were introduced to C# by [Erik Meijer](https://en.wikipedia.org/wiki/Erik_Meijer_(computer_scientist)). While it was definitely used on the .NET platform it really didn't reach mainstream adoption until Netflix ported it over to Java, naming it RxJava. From then on, numerous ports have been provided for a variety of platforms including JavaScript (RxJS). The idea behind Rx is to move towards what's called `observable streams` whereby we now think of data as streams (infinite amounts of data) and these streams can be observed. In practical terms, Rx is simply the [Observer Pattern](https://en.wikipedia.org/wiki/Observer_pattern) with a series of extensions which allow us to operate on the data. In approach it's quite similar to Futures, but one can think of a Future as returning a discrete element, whereas Rx returns a stream. However, similar to the previous, it also introduces a complete new way of thinking about our programming model, famously phrased as `"everything is a stream, and it's observable"` This implies a different way to approach problems and quite a significant shift from what we're used to when writing synchronous code. One benefit as opposed to Futures is that given it's ported to so many platforms, generally we can find a consistent API experience no matter what we use, be it C#, Java, JavaScript, or any other language where Rx is available. In addition, Rx does introduce a somewhat nicer approach to error handling. Coroutines ---------- Kotlin's approach to working with asynchronous code is using coroutines, which is the idea of suspendable computations, i.e. the idea that a function can suspend its execution at some point and resume later on. One of the benefits however of coroutines is that when it comes to the developer, writing non-blocking code is essentially the same as writing blocking code. The programming model in itself doesn't really change. Take for instance the following code: ``` fun postItem(item: Item) { launch { val token = preparePost() val post = submitPost(token, item) processPost(post) } } suspend fun preparePost(): Token { // makes a request and suspends the coroutine return suspendCoroutine { /* ... */ } } ``` This code will launch a long-running operation without blocking the main thread. The `preparePost` is what's called a `suspendable function`, thus the keyword `suspend` prefixing it. What this means as stated above, is that the function will execute, pause execution and resume at some point in time. * The function signature remains exactly the same. The only difference is `suspend` being added to it. The return type however is the type we want to be returned. * The code is still written as if we were writing synchronous code, top-down, without the need of any special syntax, beyond the use of a function called `launch` which essentially kicks off the coroutine (covered in other tutorials). * The programming model and APIs remain the same. We can continue to use loops, exception handling, etc. and there's no need to learn a complete set of new APIs. * It is platform independent. Whether we're targeting JVM, JavaScript or any other platform, the code we write is the same. Under the covers the compiler takes care of adapting it to each platform. Coroutines are not a new concept, let alone invented by Kotlin. They've been around for decades and are popular in some other programming languages such as Go. What is important to note though is that the way they're implemented in Kotlin, most of the functionality is delegated to libraries. In fact, beyond the `suspend` keyword, no other keywords are added to the language. This is somewhat different from languages such as C# that have `async` and `await` as part of the syntax. With Kotlin, these are just library functions. For more information, see the [Coroutines reference](coroutines-overview). Last modified: 10 January 2023 [This expressions](this-expressions) [Coroutines](coroutines-overview) kotlin Coroutines basics Coroutines basics ================= This section covers basic coroutine concepts. Your first coroutine -------------------- A *coroutine* is an instance of suspendable computation. It is conceptually similar to a thread, in the sense that it takes a block of code to run that works concurrently with the rest of the code. However, a coroutine is not bound to any particular thread. It may suspend its execution in one thread and resume in another one. Coroutines can be thought of as light-weight threads, but there is a number of important differences that make their real-life usage very different from threads. Run the following code to get to your first working coroutine: ``` import kotlinx.coroutines.* //sampleStart fun main() = runBlocking { // this: CoroutineScope launch { // launch a new coroutine and continue delay(1000L) // non-blocking delay for 1 second (default time unit is ms) println("World!") // print after delay } println("Hello") // main coroutine continues while a previous one is delayed } //sampleEnd ``` You will see the following result: ``` Hello World! ``` Let's dissect what this code does. [launch](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) is a *coroutine builder*. It launches a new coroutine concurrently with the rest of the code, which continues to work independently. That's why `Hello` has been printed first. [delay](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/delay.html) is a special *suspending function*. It *suspends* the coroutine for a specific time. Suspending a coroutine does not *block* the underlying thread, but allows other coroutines to run and use the underlying thread for their code. [runBlocking](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) is also a coroutine builder that bridges the non-coroutine world of a regular `fun main()` and the code with coroutines inside of `runBlocking { ... }` curly braces. This is highlighted in an IDE by `this: CoroutineScope` hint right after the `runBlocking` opening curly brace. If you remove or forget `runBlocking` in this code, you'll get an error on the [launch](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) call, since `launch` is declared only on the [CoroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html): ``` Unresolved reference: launch ``` The name of `runBlocking` means that the thread that runs it (in this case — the main thread) gets *blocked* for the duration of the call, until all the coroutines inside `runBlocking { ... }` complete their execution. You will often see `runBlocking` used like that at the very top-level of the application and quite rarely inside the real code, as threads are expensive resources and blocking them is inefficient and is often not desired. ### Structured concurrency Coroutines follow a principle of **structured concurrency** which means that new coroutines can be only launched in a specific [CoroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html) which delimits the lifetime of the coroutine. The above example shows that [runBlocking](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) establishes the corresponding scope and that is why the previous example waits until `World!` is printed after a second's delay and only then exits. In a real application, you will be launching a lot of coroutines. Structured concurrency ensures that they are not lost and do not leak. An outer scope cannot complete until all its children coroutines complete. Structured concurrency also ensures that any errors in the code are properly reported and are never lost. Extract function refactoring ---------------------------- Let's extract the block of code inside `launch { ... }` into a separate function. When you perform "Extract function" refactoring on this code, you get a new function with the `suspend` modifier. This is your first *suspending function*. Suspending functions can be used inside coroutines just like regular functions, but their additional feature is that they can, in turn, use other suspending functions (like `delay` in this example) to *suspend* execution of a coroutine. ``` import kotlinx.coroutines.* //sampleStart fun main() = runBlocking { // this: CoroutineScope launch { doWorld() } println("Hello") } // this is your first suspending function suspend fun doWorld() { delay(1000L) println("World!") } //sampleEnd ``` Scope builder ------------- In addition to the coroutine scope provided by different builders, it is possible to declare your own scope using the [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) builder. It creates a coroutine scope and does not complete until all launched children complete. [runBlocking](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) and [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) builders may look similar because they both wait for their body and all its children to complete. The main difference is that the [runBlocking](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) method *blocks* the current thread for waiting, while [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) just suspends, releasing the underlying thread for other usages. Because of that difference, [runBlocking](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) is a regular function and [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) is a suspending function. You can use `coroutineScope` from any suspending function. For example, you can move the concurrent printing of `Hello` and `World` into a `suspend fun doWorld()` function: ``` import kotlinx.coroutines.* //sampleStart fun main() = runBlocking { doWorld() } suspend fun doWorld() = coroutineScope { // this: CoroutineScope launch { delay(1000L) println("World!") } println("Hello") } //sampleEnd ``` This code also prints: ``` Hello World! ``` Scope builder and concurrency ----------------------------- A [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) builder can be used inside any suspending function to perform multiple concurrent operations. Let's launch two concurrent coroutines inside a `doWorld` suspending function: ``` import kotlinx.coroutines.* //sampleStart // Sequentially executes doWorld followed by "Done" fun main() = runBlocking { doWorld() println("Done") } // Concurrently executes both sections suspend fun doWorld() = coroutineScope { // this: CoroutineScope launch { delay(2000L) println("World 2") } launch { delay(1000L) println("World 1") } println("Hello") } //sampleEnd ``` Both pieces of code inside `launch { ... }` blocks execute *concurrently*, with `World 1` printed first, after a second from start, and `World 2` printed next, after two seconds from start. A [coroutineScope](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/coroutine-scope.html) in `doWorld` completes only after both are complete, so `doWorld` returns and allows `Done` string to be printed only after that: ``` Hello World 1 World 2 Done ``` An explicit job --------------- A [launch](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/launch.html) coroutine builder returns a [Job](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-job/index.html) object that is a handle to the launched coroutine and can be used to explicitly wait for its completion. For example, you can wait for completion of the child coroutine and then print "Done" string: ``` import kotlinx.coroutines.* fun main() = runBlocking { //sampleStart val job = launch { // launch a new coroutine and keep a reference to its Job delay(1000L) println("World!") } println("Hello") job.join() // wait until child coroutine completes println("Done") //sampleEnd } ``` This code produces: ``` Hello World! Done ``` Coroutines are light-weight --------------------------- Coroutines are less resource-intensive than JVM threads. Code that exhausts the JVM's available memory when using threads can be expressed using coroutines without hitting resource limits. For example, the following code launches 100000 distinct coroutines that each wait 5 seconds and then print a period ('.') while consuming very little memory: ``` import kotlinx.coroutines.* fun main() = runBlocking { repeat(100_000) { // launch a lot of coroutines launch { delay(5000L) print(".") } } } ``` If you write the same program using threads (remove `runBlocking`, replace `launch` with `thread`, and replace `delay` with `Thread.sleep`), it will likely consume too much memory and throw an out-of-memory error. Last modified: 10 January 2023 [Coroutines guide](coroutines-guide) [Coroutines and channels − tutorial](coroutines-and-channels)
programming_docs
kotlin Run tests with Kotlin Multiplatform Run tests with Kotlin Multiplatform =================================== By default, Kotlin supports running tests for JVM, JS, Android, Linux, Windows, macOS as well as iOS, watchOS, and tvOS simulators. To run tests for other Kotlin/Native targets, you need to configure them manually in an appropriate environment, emulator, or test framework. Required dependencies --------------------- The [`kotlin.test` API](https://kotlinlang.org/api/latest/kotlin.test/) is available for multiplatform tests. When you [create a multiplatform project](multiplatform-library), the Project Wizard automatically adds test dependencies to common and platform-specific source sets. If you didn't use the Project Wizard to create your project, you can [add the dependencies manually](gradle-configure-project#set-dependencies-on-test-libraries). Run tests for one or more targets --------------------------------- To run tests for all targets, run the `check` task. To run tests for a particular target suitable for testing, run a test task `<targetName>Test`. Test shared code ---------------- For testing shared code, you can use [actual declarations](multiplatform-connect-to-apis) in your tests. For example, to test the shared code in `commonMain`: ``` expect object Platform { val name: String } fun hello(): String = "Hello from ${Platform.name}" class Proxy { fun proxyHello() = hello() } ``` You can use the following test in `commonTest`: ``` import kotlin.test.Test import kotlin.test.assertTrue class SampleTests { @Test fun testProxy() { assertTrue(Proxy().proxyHello().isNotEmpty()) } } ``` And the following test in `iosTest`: ``` import kotlin.test.Test import kotlin.test.assertTrue class SampleTestsIOS { @Test fun testHello() { assertTrue("iOS" in hello()) } } ``` You can also learn how to create and run multiplatform tests in the [Create and publish a multiplatform library – tutorial](multiplatform-library#test-your-library). Last modified: 10 January 2023 [Adding iOS dependencies](multiplatform-mobile-ios-dependencies) [Configure compilations](multiplatform-configure-compilations) kotlin Kotlin roadmap Kotlin roadmap ============== | **Last modified on** | December 2022 | | --- | --- | | **Next update** | **June 2023** | Welcome to the Kotlin roadmap! Get a sneak peek into the priorities of the Kotlin Team. Key priorities -------------- The goal of this roadmap is to give you a big picture. Here's a list of our key projects – the most important things we focus on delivering: * **K2 compiler**: a rewrite of the Kotlin compiler optimized for speed, parallelism, and unification. It will also let us introduce many anticipated language features. * **K2-based IntelliJ plugin**: much faster code completion, highlighting, and search, together with a more stable code analysis. * **Kotlin Multiplatform Mobile**: promote the technology to Stable by improving the toolchain stability and documentation, and ensuring compatibility guarantees. * **Experience of library authors**: a set of documentation and tools helping to set up, develop, and publish Kotlin libraries. Kotlin roadmap by subsystem --------------------------- To view the biggest projects we're working on, visit the [YouTrack board](https://youtrack.jetbrains.com/agiles/153-1251/current) or the [Roadmap details](#roadmap-details) table. If you have any questions or feedback about the roadmap or the items on it, feel free to post them to [YouTrack tickets](https://youtrack.jetbrains.com/issues?q=project:%20KT,%20KTIJ%20tag:%20%7BRoadmap%20Item%7D%20%23Unresolved%20) or in the [#kotlin-roadmap](https://kotlinlang.slack.com/archives/C01AAJSG3V4) channel of Kotlin Slack ([request an invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). ### YouTrack board Visit the [roadmap board in our issue tracker YouTrack](https://youtrack.jetbrains.com/agiles/153-1251/current) ![YouTrack](https://kotlinlang.org/docs/images/youtrack-logo.png "YouTrack") ![Roadmap board in YouTrack](https://kotlinlang.org/docs/images/roadmap-board.png "Roadmap board in YouTrack")### Roadmap details | Subsystem | In focus now | | --- | --- | | **Language** | * [Introduce special syntax for `until` operator](https://youtrack.jetbrains.com/issue/KT-15613) * [Provide modern and performant replacement for `Enum.values()`](https://youtrack.jetbrains.com/issue/KT-48872) * [Support non-local `break` and `continue`](https://youtrack.jetbrains.com/issue/KT-1436) * [Design and implement solution for `toString` on objects](https://youtrack.jetbrains.com/issue/KT-4107) | | **Compiler** | * [Release K2 Beta](https://youtrack.jetbrains.com/issue/KT-52604) * [Fix issues related to inline classes on the JVM](https://youtrack.jetbrains.com/issue/KT-49514) * [Stabilize JVM-specific experimental features](https://youtrack.jetbrains.com/issue/KT-46770) * [Implement an experimental version of Kotlin/Wasm compiler backend](https://youtrack.jetbrains.com/issue/KT-46773) | | **Multiplatform** | * 🆕 [Promote Kotlin Multiplatform Mobile to Stable](https://youtrack.jetbrains.com/issue/KT-55513) * 🆕 [Improve the new Kotlin/Native memory manager robustness and performance and deprecate the old one](https://youtrack.jetbrains.com/issue/KT-55512) * [Stabilize klib: keep binary compatibility easier for library authors](https://youtrack.jetbrains.com/issue/KT-52600) * [Improve exporting Kotlin code to Objective-C](https://youtrack.jetbrains.com/issue/KT-42297) * [Improve Kotlin/Native compilation time](https://youtrack.jetbrains.com/issue/KT-42294) | | **Tooling** | * 🆕 [First public release of K2-based IntelliJ plugin](https://youtrack.jetbrains.com/issue/KTIJ-23988) * 🆕 [Improve performance and code analysis stability of the current IDE plugin](https://youtrack.jetbrains.com/issue/KTIJ-23989) * 🆕 [Expose stable compiler arguments in Gradle DSL](https://youtrack.jetbrains.com/issue/KT-55515) * 🆕 [Release the Experimental version of the Kotlin Notebooks IJ IDEA plugin](https://youtrack.jetbrains.com/issue/KTIJ-23990) * [Improve Kotlin scripting and experience with `.gradle.kts`](https://youtrack.jetbrains.com/issue/KT-49511) * [Provide better experience with Kotlin Daemon](https://youtrack.jetbrains.com/issue/KT-49532) * [Improve the performance of Gradle incremental compilation](https://youtrack.jetbrains.com/issue/KT-42309) | | **Library ecosystem** | * 🆕 [Improve KDoc experience](https://youtrack.jetbrains.com/issue/KT-55073) * 🆕 [Provide a Kotlin API guide for libraries authors](https://youtrack.jetbrains.com/issue/KT-55077) * [Release `kotlinx-metadata-jvm` as Stable](https://youtrack.jetbrains.com/issue/KT-48011) * [Stabilize `kotlinx-kover`](https://youtrack.jetbrains.com/issue/KT-49527) * [Release `kotlinx-coroutines` 1.7](https://youtrack.jetbrains.com/issue/KT-49529) * [Stabilize and document `atomicfu`](https://youtrack.jetbrains.com/issue/KT-46786) * [Improve `kotlinx-datetime` library](https://youtrack.jetbrains.com/issue/KT-42315) * [Continue to develop and stabilize the standard library](https://youtrack.jetbrains.com/issue/KT-52601) * [Release Dokka as Stable](https://youtrack.jetbrains.com/issue/KT-48998) | What's changed since May 2022 ----------------------------- ### Completed items We've **completed** the following items from the previous roadmap: * ✅ Compiler core: [Maintain the current compiler](https://youtrack.jetbrains.com/issue/KT-42286) * ✅ Kotlin/JVM: [Support kapt in JVM IR](https://youtrack.jetbrains.com/issue/KT-49682) * ✅ Kotlin/JVM: [Maintain the new JVM IR backend](https://youtrack.jetbrains.com/issue/KT-46767) * ✅ Kotlin/JVM: [Improve the new JVM IR backend compilation time](https://youtrack.jetbrains.com/issue/KT-46768) * ✅ Kotlin/Native: [Provide binary compatibility between incremental releases](https://youtrack.jetbrains.com/issue/KT-42293) * ✅ Kotlin/Native: [Promote new memory manager to Beta and enable it by default](https://youtrack.jetbrains.com/issue/KT-52595) * ✅ Kotlin/JS: [Make the new JS IR backend Stable](https://youtrack.jetbrains.com/issue/KT-42289) * ✅ Kotlin/JS: [Maintain the old JS backend by fixing critical bugs](https://youtrack.jetbrains.com/issue/KT-42291) * ✅ Multiplatform: [Promote Kotlin Multiplatform Mobile to Beta](https://youtrack.jetbrains.com/issue/KT-52596) * ✅ Libraries: [Release `kotlinx-serialization` 1.4](https://youtrack.jetbrains.com/issue/KT-49528) * ✅ IDE: [Stabilize code analysis](https://youtrack.jetbrains.com/issue/KTIJ-21906) * ✅ IDE: [Make update of compiler/platform versions faster](https://youtrack.jetbrains.com/issue/KTIJ-20044) * ✅ IDE: [Improve Multiplatform project support](https://youtrack.jetbrains.com/issue/KTIJ-20045) * ✅ IDE: [Stabilize Eclipse plugin](https://youtrack.jetbrains.com/issue/KTIJ-20046) * ✅ IDE: [Prototype the IDE plugin with the new compiler frontend](https://youtrack.jetbrains.com/issue/KTIJ-18195) * ✅ IDE: [Improve IDE performance](https://youtrack.jetbrains.com/issue/KTIJ-18174) * ✅ IDE: [Improve debugging experience](https://youtrack.jetbrains.com/issue/KTIJ-18572) * ✅ Website: [Make the Kotlin website mobile friendly](https://youtrack.jetbrains.com/issue/KT-44339) * ✅ Website: [Make the UI and navigation consistent](https://youtrack.jetbrains.com/issue/KT-46791) ### New items We've **added** the following items to the roadmap: * ℹ️ Language: [List of all upcoming language features](https://youtrack.jetbrains.com/issue/KT-54620) * 🆕 Multiplatform: Promote Kotlin Multiplatform Mobile to Stable * 🆕 Multiplatform: Improve the new Kotlin/Native memory manager robustness and performance and deprecate the old one * 🆕 Tooling: First public release of K2-based IntelliJ plugin * 🆕 Tooling: Improve performance and code analysis stability of the current IDE plugin * 🆕 Tooling: Expose stable compiler arguments in Gradle DSL * 🆕 Tooling: Kotlin Notebooks IDEA plugin * 🆕 Libraries: [Improve KDoc experience](https://youtrack.jetbrains.com/issue/KT-55073) * 🆕 Libraries: [Provide a Kotlin API guide for libraries authors](https://youtrack.jetbrains.com/issue/KT-55077) ### Removed items We've **removed** the following items from the roadmap: * ❌ Language: [Research and prototype namespace-based solution for statics and static extensions](https://youtrack.jetbrains.com/issue/KT-11968) * ❌ Language: [Multiple receivers on extension functions/properties](https://youtrack.jetbrains.com/issue/KT-10468) * ❌ Language: [Support inline sealed classes](https://youtrack.jetbrains.com/issue/KT-27576) * ❌ K2 compiler: [Stabilize the K2 Compiler Plugin API](https://youtrack.jetbrains.com/issue/KT-49508) * ❌ K2 compiler: [Provide Alpha support for Native in the K2 platform](https://youtrack.jetbrains.com/issue/KT-52594) * ❌ K2 compiler: [Provide Alpha support for JS in the K2 platform](https://youtrack.jetbrains.com/issue/KT-52593) * ❌ K2 compiler: [Support Multiplatform in the K2 platform](https://youtrack.jetbrains.com/issue/KT-52597) * ❌ Multiplatform: [Improve stability and robustness of the multiplatform toolchain](https://youtrack.jetbrains.com/issue/KT-49525) * ❌ Multiplatform: [Improve Android support in Multiplatform projects](https://youtrack.jetbrains.com/issue/KT-52599) * ❌ Build tools: [Make compilation avoidance support Stable for Gradle](https://youtrack.jetbrains.com/issue/KT-52603) * ❌ Website: [Improve Kotlin Playground](https://youtrack.jetbrains.com/issue/KT-49536) ### Items in progress All other previously identified roadmap items are in progress. You can check their [YouTrack tickets](https://youtrack.jetbrains.com/issues?q=project:%20KT,%20KTIJ%20tag:%20%7BRoadmap%20Item%7D%20%23Unresolved%20) for updates. Last modified: 10 January 2023 [Kotlin plugin releases](plugin-releases) [Collections overview](collections-overview) kotlin Install the EAP Plugin for IntelliJ IDEA or Android Studio Install the EAP Plugin for IntelliJ IDEA or Android Studio ========================================================== You can follow these instructions to install [the preview version of the Kotlin Plugin for IntelliJ IDEA or Android Studio](eap#build-details). 1. Select **Tools** | **Kotlin** | **Configure Kotlin Plugin Updates**. ![Select Kotlin Plugin Updates](https://kotlinlang.org/docs/images/idea-kotlin-plugin-updates.png "Select Kotlin Plugin Updates") 2. In the **Update channel** list, select the **Early Access Preview** channel. ![Select the EAP update channel](https://kotlinlang.org/docs/images/idea-kotlin-update-channel.png "Select the EAP update channel") 3. Click **Check again**. The latest EAP build version appears. ![Install the EAP build](https://kotlinlang.org/docs/images/idea-latest-kotlin-eap.png "Install the EAP build") 4. Click **Install**. If you want to work on existing projects that were created before installing the EAP version, you need to [configure your build for EAP](configure-build-for-eap). If you run into any problems ---------------------------- * Report an issue to [our issue tracker, YouTrack](https://kotl.in/issue). * Find help in the [#eap channel in Kotlin Slack](https://app.slack.com/client/T09229ZC6/C0KLZSCHF) ([get an invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). * Roll back to the latest stable version: in **Tools | Kotlin | Configure Kotlin Plugin Updates**, select the **Stable** update channel and click **Install**. Last modified: 10 January 2023 [Participate in the Kotlin Early Access Preview](eap) [Configure your build for EAP](configure-build-for-eap) kotlin Multiplatform Gradle DSL reference Multiplatform Gradle DSL reference ================================== The Kotlin Multiplatform Gradle plugin is a tool for creating [Kotlin Multiplatform](multiplatform) projects. Here we provide a reference of its contents; use it as a reminder when writing Gradle build scripts for Kotlin Multiplatform projects. Learn the [concepts of Kotlin Multiplatform projects, how to create and configure them](multiplatform-get-started). Id and version -------------- The fully qualified name of the Kotlin Multiplatform Gradle plugin is `org.jetbrains.kotlin.multiplatform`. If you use the Kotlin Gradle DSL, you can apply the plugin with `kotlin("multiplatform")`. The plugin versions match the Kotlin release versions. The most recent version is 1.8.0. ``` plugins { kotlin("multiplatform") version "1.8.0" } ``` ``` plugins { id 'org.jetbrains.kotlin.multiplatform' version '1.8.0' } ``` Top-level blocks ---------------- `kotlin` is the top-level block for multiplatform project configuration in the Gradle build script. Inside `kotlin`, you can write the following blocks: | **Block** | **Description** | | --- | --- | | *<targetName>* | Declares a particular target of a project. The names of available targets are listed in the [Targets](#targets) section. | | `targets` | All targets of the project. | | `presets` | All predefined targets. Use this for [configuring multiple predefined targets](#targets) at once. | | `sourceSets` | Configures predefined and declares custom [source sets](#source-sets) of the project. | Targets ------- *Target* is a part of the build responsible for compiling, testing, and packaging a piece of software aimed for one of the supported platforms. Kotlin provides target presets for each platform. See how to [use a target preset](multiplatform-set-up-targets). Each target can have one or more [compilations](#compilations). In addition to default compilations for test and production purposes, you can [create custom compilations](multiplatform-configure-compilations#create-a-custom-compilation). The targets of a multiplatform project are described in the corresponding blocks inside `kotlin`, for example, `jvm`, `android`, `iosArm64`. The complete list of available targets is the following: | Target platform | Target preset | Comments | | --- | --- | --- | | Kotlin/JVM | `jvm` | | | Kotlin/JS | `js` | Select the execution environment:* `browser {}` for applications running in the browser. * `nodejs {}` for applications running on Node.js. Learn more in [Setting up a Kotlin/JS project](js-project-setup#execution-environments). | | Android applications and libraries | `android` | Manually apply an Android Gradle plugin – `com.android.application` or `com.android.library`. You can only create one Android target per Gradle subproject. | | Android NDK | * `androidNativeArm32` — [Android NDK](https://developer.android.com/ndk) on ARM (ARM32) platforms * `androidNativeArm64` — [Android NDK](https://developer.android.com/ndk) on ARM64 platforms * `androidNativeX86` — [Android NDK](https://developer.android.com/ndk) on x86 platforms * `androidNativeX64` — [Android NDK](https://developer.android.com/ndk) on x86\_64 platforms | The 64-bit target requires a Linux or macOS host. You can build the 32-bit target on any supported host. | | iOS | * `iosArm32` — Apple iOS on ARM (ARM32) platforms (Apple iPhone 5 and earlier) * `iosArm64` — Apple iOS on ARM64 platforms (Apple iPhone 5s and newer) * `iosX64` — Apple iOS simulator on x86\_64 platforms * `iosSimulatorArm64` — Apple iOS simulator on Apple Silicon platforms | Requires a macOS host with [Xcode](https://apps.apple.com/us/app/xcode/id497799835) and its command-line tools installed. | | watchOS | * `watchosArm32` — Apple watchOS on ARM32 platforms (Apple Watch Series 3 and earlier) * `watchosArm64` — Apple watchOS on ARM64\_32 platforms (Apple Watch Series 4 and newer) * `watchosDeviceArm64` — Apple watchOS on ARM64 platforms * `watchosX86` — Apple watchOS 32-bit simulator (watchOS 6.3 and earlier) on x86\_64 platforms * `watchosX64` — Apple watchOS 64-bit simulator (watchOS 7.0 and newer) on x86\_64 platforms * `watchosSimulatorArm64` — Apple watchOS simulator on Apple Silicon platforms | Requires a macOS host with [Xcode](https://apps.apple.com/us/app/xcode/id497799835) and its command-line tools installed. | | tvOS | * `tvosArm64` — Apple tvOS on ARM64 platforms (Apple TV 4th generation and newer) * `tvosX64` — Apple tvOS simulator on x86\_64 platforms * `tvosSimulatorArm64` — Apple tvOS simulator on Apple Silicon platforms | Requires a macOS host with [Xcode](https://apps.apple.com/us/app/xcode/id497799835) and its command-line tools installed. | | macOS | * `macosX64` — Apple macOS on x86\_64 platforms * `macosArm64` — Apple macOS on Apple Silicon platforms | Requires a macOS host with [Xcode](https://apps.apple.com/us/app/xcode/id497799835) and its command-line tools installed. | | Linux | * `linuxArm64` — Linux on ARM64 platforms, for example, Raspberry Pi * `linuxArm32Hfp` — Linux on hard-float ARM (ARM32) platforms * `linuxMips32` — Linux on MIPS platforms * `linuxMipsel32` — Linux on little-endian MIPS (mipsel) platforms * `linuxX64` — Linux on x86\_64 platforms | Linux MIPS targets (`linuxMips32` and `linuxMipsel32`) require a Linux host. You can build other Linux targets on any supported host. | | Windows | * `mingwX64` — 64-bit Microsoft Windows * `mingwX86` — 32-bit Microsoft Windows | | | WebAssembly | `wasm32` | | ``` kotlin { jvm() iosX64() macosX64() js().browser() } ``` Configuration of a target can include two parts: * [Common configuration](#common-target-configuration) available for all targets. * Target-specific configuration. Each target can have one or more [compilations](#compilations). ### Common target configuration In any target block, you can use the following declarations: | **Name** | **Description** | | --- | --- | | `attributes` | Attributes used for [disambiguating targets](multiplatform-set-up-targets#distinguish-several-targets-for-one-platform) for a single platform. | | `preset` | The preset that the target has been created from, if any. | | `platformType` | Designates the Kotlin platform of this target. Available values: `jvm`, `androidJvm`, `js`, `native`, `common`. | | `artifactsTaskName` | The name of the task that builds the resulting artifacts of this target. | | `components` | The components used to setup Gradle publications. | ### JVM targets In addition to [common target configuration](#common-target-configuration), `jvm` targets have a specific function: | **Name** | **Description** | | --- | --- | | `withJava()` | Includes Java sources into the JVM target's compilations. | Use this function for projects that contain both Java and Kotlin source files. Note that the default source directories for Java sources don't follow the Java plugin's defaults. Instead, they are derived from the Kotlin source sets. For example, if the JVM target has the default name `jvm`, the paths are `src/jvmMain/java` (for production Java sources) and `src/jvmTest/java` for test Java sources. Learn more about [Java sources in JVM compilations](multiplatform-configure-compilations#use-java-sources-in-jvm-compilations). ``` kotlin { jvm { withJava() } } ``` ### JavaScript targets The `js` block describes the configuration of JavaScript targets. It can contain one of two blocks depending on the target execution environment: | **Name** | **Description** | | --- | --- | | `browser` | Configuration of the browser target. | | `nodejs` | Configuration of the Node.js target. | Learn more about [configuring Kotlin/JS projects](js-project-setup). #### Browser `browser` can contain the following configuration blocks: | **Name** | **Description** | | --- | --- | | `testRuns` | Configuration of test execution. | | `runTask` | Configuration of project running. | | `webpackTask` | Configuration of project bundling with [Webpack](https://webpack.js.org/). | | `dceTask` | Configuration of [Dead Code Elimination](javascript-dce). | | `distribution` | Path to output files. | ``` kotlin { js().browser { webpackTask { /* ... */ } testRuns { /* ... */ } dceTask { keep("myKotlinJsApplication.org.example.keepFromDce") } distribution { directory = File("$projectDir/customdir/") } } } ``` #### Node.js `nodejs` can contain configurations of test and run tasks: | **Name** | **Description** | | --- | --- | | `testRuns` | Configuration of test execution. | | `runTask` | Configuration of project running. | ``` kotlin { js().nodejs { runTask { /* ... */ } testRuns { /* ... */ } } } ``` ### Native targets For native targets, the following specific blocks are available: | **Name** | **Description** | | --- | --- | | `binaries` | Configuration of [binaries](#binaries) to produce. | | `cinterops` | Configuration of [interop with C libraries](#cinterops). | #### Binaries There are the following kinds of binaries: | **Name** | **Description** | | --- | --- | | `executable` | Product executable. | | `test` | Test executable. | | `sharedLib` | Shared library. | | `staticLib` | Static library. | | `framework` | Objective-C framework. | ``` kotlin { linuxX64 { // Use your target instead. binaries { executable { // Binary configuration. } } } } ``` For binaries configuration, the following parameters are available: | **Name** | **Description** | | --- | --- | | `compilation` | The compilation from which the binary is built. By default, `test` binaries are based on the `test` compilation while other binaries - on the `main` compilation. | | `linkerOpts` | Options passed to a system linker during binary building. | | `baseName` | Custom base name for the output file. The final file name will be formed by adding system-dependent prefix and postfix to this base name. | | `entryPoint` | The entry point function for executable binaries. By default, it's `main()` in the root package. | | `outputFile` | Access to the output file. | | `linkTask` | Access to the link task. | | `runTask` | Access to the run task for executable binaries. For targets other than `linuxX64`, `macosX64`, or `mingwX64` the value is `null`. | | `isStatic` | For Objective-C frameworks. Includes a static library instead of a dynamic one. | ``` binaries { executable("my_executable", listOf(RELEASE)) { // Build a binary on the basis of the test compilation. compilation = compilations["test"] // Custom command line options for the linker. linkerOpts = mutableListOf("-L/lib/search/path", "-L/another/search/path", "-lmylib") // Base name for the output file. baseName = "foo" // Custom entry point function. entryPoint = "org.example.main" // Accessing the output file. println("Executable path: ${outputFile.absolutePath}") // Accessing the link task. linkTask.dependsOn(additionalPreprocessingTask) // Accessing the run task. // Note that the runTask is null for non-host platforms. runTask?.dependsOn(prepareForRun) } framework("my_framework" listOf(RELEASE)) { // Include a static library instead of a dynamic one into the framework. isStatic = true } } ``` ``` binaries { executable('my_executable', [RELEASE]) { // Build a binary on the basis of the test compilation. compilation = compilations.test // Custom command line options for the linker. linkerOpts = ['-L/lib/search/path', '-L/another/search/path', '-lmylib'] // Base name for the output file. baseName = 'foo' // Custom entry point function. entryPoint = 'org.example.main' // Accessing the output file. println("Executable path: ${outputFile.absolutePath}") // Accessing the link task. linkTask.dependsOn(additionalPreprocessingTask) // Accessing the run task. // Note that the runTask is null for non-host platforms. runTask?.dependsOn(prepareForRun) } framework('my_framework' [RELEASE]) { // Include a static library instead of a dynamic one into the framework. isStatic = true } } ``` Learn more about [building native binaries](multiplatform-build-native-binaries). #### CInterops `cinterops` is a collection of descriptions for interop with native libraries. To provide an interop with a library, add an entry to `cinterops` and define its parameters: | **Name** | **Description** | | --- | --- | | `defFile` | `def` file describing the native API. | | `packageName` | Package prefix for the generated Kotlin API. | | `compilerOpts` | Options to pass to the compiler by the cinterop tool. | | `includeDirs` | Directories to look for headers. | Learn more how to [configure interop with native languages](multiplatform-configure-compilations#configure-interop-with-native-languages). ``` kotlin { linuxX64 { // Replace with a target you need. compilations.getByName("main") { val myInterop by cinterops.creating { // Def-file describing the native API. // The default path is src/nativeInterop/cinterop/<interop-name>.def defFile(project.file("def-file.def")) // Package to place the Kotlin API generated. packageName("org.sample") // Options to be passed to compiler by cinterop tool. compilerOpts("-Ipath/to/headers") // Directories for header search (an analogue of the -I<path> compiler option). includeDirs.allHeaders("path1", "path2") // A shortcut for includeDirs.allHeaders. includeDirs("include/directory", "another/directory") } val anotherInterop by cinterops.creating { /* ... */ } } } } ``` ``` kotlin { linuxX64 { // Replace with a target you need. compilations.main { cinterops { myInterop { // Def-file describing the native API. // The default path is src/nativeInterop/cinterop/<interop-name>.def defFile project.file("def-file.def") // Package to place the Kotlin API generated. packageName 'org.sample' // Options to be passed to compiler by cinterop tool. compilerOpts '-Ipath/to/headers' // Directories for header search (an analogue of the -I<path> compiler option). includeDirs.allHeaders("path1", "path2") // A shortcut for includeDirs.allHeaders. includeDirs("include/directory", "another/directory") } anotherInterop { /* ... */ } } } } } ``` ### Android targets The Kotlin Multiplatform plugin contains two specific functions for android targets. Two functions help you configure [build variants](https://developer.android.com/studio/build/build-variants): | **Name** | **Description** | | --- | --- | | `publishLibraryVariants()` | Specifies build variants to publish. Learn more about [publishing Android libraries](multiplatform-publish-lib#publish-an-android-library). | | `publishAllLibraryVariants()` | Publishes all build variants. | ``` kotlin { android { publishLibraryVariants("release", "debug") } } ``` Learn more about [compilation for Android](multiplatform-configure-compilations#compilation-for-android). Source sets ----------- The `sourceSets` block describes source sets of the project. A source set contains Kotlin source files that participate in compilations together, along with their resources, dependencies, and language settings. A multiplatform project contains [predefined](#predefined-source-sets) source sets for its targets; developers can also create [custom](#custom-source-sets) source sets for their needs. ### Predefined source sets Predefined source sets are set up automatically upon creation of a multiplatform project. Available predefined source sets are the following: | **Name** | **Description** | | --- | --- | | `commonMain` | Code and resources shared between all platforms. Available in all multiplatform projects. Used in all main [compilations](#compilations) of a project. | | `commonTest` | Test code and resources shared between all platforms. Available in all multiplatform projects. Used in all test compilations of a project. | | *<targetName><compilationName>* | Target-specific sources for a compilation. *<targetName>* is the name of a predefined target and *<compilationName>* is the name of a compilation for this target. Examples: `jsTest`, `jvmMain`. | With Kotlin Gradle DSL, the sections of predefined source sets should be marked `by getting`. ``` kotlin { sourceSets { val commonMain by getting { /* ... */ } } } ``` ``` kotlin { sourceSets { commonMain { /* ... */ } } } ``` Learn more about [source sets](multiplatform-discover-project#source-sets). ### Custom source sets Custom source sets are created by the project developers manually. To create a custom source set, add a section with its name inside the `sourceSets` section. If using Kotlin Gradle DSL, mark custom source sets `by creating`. ``` kotlin { sourceSets { val myMain by creating { /* ... */ } // create a new source set by the name 'MyMain' } } ``` ``` kotlin { sourceSets { myMain { /* ... */ } // create or configure a source set by the name 'myMain' } } ``` Note that a newly created source set isn't connected to other ones. To use it in the project's compilations, [connect it with other source sets](multiplatform-share-on-platforms#configure-the-hierarchical-structure-manually). ### Source set parameters Configurations of source sets are stored inside the corresponding blocks of `sourceSets`. A source set has the following parameters: | **Name** | **Description** | | --- | --- | | `kotlin.srcDir` | Location of Kotlin source files inside the source set directory. | | `resources.srcDir` | Location of resources inside the source set directory. | | `dependsOn` | [Connection with another source set](multiplatform-share-on-platforms#configure-the-hierarchical-structure-manually). | | `dependencies` | [Dependencies](#dependencies) of the source set. | | `languageSettings` | [Language settings](#language-settings) applied to the source set. | ``` kotlin { sourceSets { val commonMain by getting { kotlin.srcDir("src") resources.srcDir("res") dependencies { /* ... */ } } } } ``` ``` kotlin { sourceSets { commonMain { kotlin.srcDir('src') resources.srcDir('res') dependencies { /* ... */ } } } } ``` Compilations ------------ A target can have one or more compilations, for example, for production or testing. There are [predefined compilations](#predefined-compilations) that are added automatically upon target creation. You can additionally create [custom compilations](#custom-compilations). To refer to all or some particular compilations of a target, use the `compilations` object collection. From `compilations`, you can refer to a compilation by its name. Learn more about [configuring compilations](multiplatform-configure-compilations). ### Predefined compilations Predefined compilations are created automatically for each target of a project except for Android targets. Available predefined compilations are the following: | **Name** | **Description** | | --- | --- | | `main` | Compilation for production sources. | | `test` | Compilation for tests. | ``` kotlin { jvm { val main by compilations.getting { output // get the main compilation output } compilations["test"].runtimeDependencyFiles // get the test runtime classpath } } ``` ``` kotlin { jvm { compilations.main.output // get the main compilation output compilations.test.runtimeDependencyFiles // get the test runtime classpath } } ``` ### Custom compilations In addition to predefined compilations, you can create your own custom compilations. To create a custom compilation, add a new item into the `compilations` collection. If using Kotlin Gradle DSL, mark custom compilations `by creating`. Learn more about creating a [custom compilation](multiplatform-configure-compilations#create-a-custom-compilation). ``` kotlin { jvm() { compilations { val integrationTest by compilations.creating { defaultSourceSet { dependencies { /* ... */ } } // Create a test task to run the tests produced by this compilation: tasks.register<Test>("integrationTest") { /* ... */ } } } } } ``` ``` kotlin { jvm() { compilations.create('integrationTest') { defaultSourceSet { dependencies { /* ... */ } } // Create a test task to run the tests produced by this compilation: tasks.register('jvmIntegrationTest', Test) { /* ... */ } } } } ``` ### Compilation parameters A compilation has the following parameters: | **Name** | **Description** | | --- | --- | | `defaultSourceSet` | The compilation's default source set. | | `kotlinSourceSets` | Source sets participating in the compilation. | | `allKotlinSourceSets` | Source sets participating in the compilation and their connections via `dependsOn()`. | | `compilerOptions` | Compiler options applied to the compilation. For the list of available options, see [Compiler options](gradle-compiler-options). | | `compileKotlinTask` | Gradle task for compiling Kotlin sources. | | `compileKotlinTaskName` | Name of `compileKotlinTask`. | | `compileAllTaskName` | Name of the Gradle task for compiling all sources of a compilation. | | `output` | The compilation output. | | `compileDependencyFiles` | Compile-time dependency files (classpath) of the compilation. | | `runtimeDependencyFiles` | Runtime dependency files (classpath) of the compilation. | ``` kotlin { jvm { val main by compilations.getting { compilerOptions.configure { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget.set(JvmTarget.JVM_1_8) } compileKotlinTask // get the Kotlin task 'compileKotlinJvm' output // get the main compilation output } compilations["test"].runtimeDependencyFiles // get the test runtime classpath } // Configure all compilations of all targets: targets.all { compilations.all { compilerOptions.configure { allWarningsAsErrors.set(true) } } } } ``` ``` kotlin { jvm { compilations.main.compilerOptions.configure { // Setup the Kotlin compiler options for the 'main' compilation: jvmTarget.set(JvmTarget.JVM_1_8) } compilations.main.compileKotlinTask // get the Kotlin task 'compileKotlinJvm' compilations.main.output // get the main compilation output compilations.test.runtimeDependencyFiles // get the test runtime classpath } // Configure all compilations of all targets: targets.all { compilations.all { compilerOptions.configure { allWarningsAsError.set(true) } } } } ``` Dependencies ------------ The `dependencies` block of the source set declaration contains the dependencies of this source set. Learn more about [configuring dependencies](gradle-configure-project). There are four types of dependencies: | **Name** | **Description** | | --- | --- | | `api` | Dependencies used in the API of the current module. | | `implementation` | Dependencies used in the module but not exposed outside it. | | `compileOnly` | Dependencies used only for compilation of the current module. | | `runtimeOnly` | Dependencies available at runtime but not visible during compilation of any module. | ``` kotlin { sourceSets { val commonMain by getting { dependencies { api("com.example:foo-metadata:1.0") } } val jvm6Main by getting { dependencies { implementation("com.example:foo-jvm6:1.0") } } } } ``` ``` kotlin { sourceSets { commonMain { dependencies { api 'com.example:foo-metadata:1.0' } } jvm6Main { dependencies { implementation 'com.example:foo-jvm6:1.0' } } } } ``` Additionally, source sets can depend on each other and form a hierarchy. In this case, the [dependsOn()](#source-set-parameters) relation is used. Source set dependencies can also be declared in the top-level `dependencies` block of the build script. In this case, their declarations follow the pattern `<sourceSetName><DependencyKind>`, for example, `commonMainApi`. ``` dependencies { "commonMainApi"("com.example:foo-common:1.0") "jvm6MainApi"("com.example:foo-jvm6:1.0") } ``` ``` dependencies { commonMainApi 'com.example:foo-common:1.0' jvm6MainApi 'com.example:foo-jvm6:1.0' } ``` Language settings ----------------- The `languageSettings` block of a source set defines certain aspects of project analysis and build. The following language settings are available: | **Name** | **Description** | | --- | --- | | `languageVersion` | Provides source compatibility with the specified version of Kotlin. | | `apiVersion` | Allows using declarations only from the specified version of Kotlin bundled libraries. | | `enableLanguageFeature` | Enables the specified language feature. The available values correspond to the language features that are currently experimental or have been introduced as such at some point. | | `optIn` | Allows using the specified [opt-in annotation](opt-in-requirements). | | `progressiveMode` | Enables the [progressive mode](whatsnew13#progressive-mode). | ``` kotlin { sourceSets.all { languageSettings.apply { languageVersion = "1.8" // possible values: "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" apiVersion = "1.8" // possible values: "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "1.9" enableLanguageFeature("InlineClasses") // language feature name optIn("kotlin.ExperimentalUnsignedTypes") // annotation FQ-name progressiveMode = true // false by default } } } ``` ``` kotlin { sourceSets.all { languageSettings { languageVersion = '1.8' // possible values: '1.4', '1.5', '1.6', '1.7', '1.8', '1.9' apiVersion = '1.8' // possible values: '1.3', '1.4', '1.5', '1.6', '1.7', '1.8', '1.9' enableLanguageFeature('InlineClasses') // language feature name optIn('kotlin.ExperimentalUnsignedTypes') // annotation FQ-name progressiveMode = true // false by default } } } ``` Last modified: 10 January 2023 [Build final native binaries](multiplatform-build-native-binaries) [Samples](multiplatform-mobile-samples)
programming_docs
kotlin Test code using JUnit in JVM – tutorial Test code using JUnit in JVM – tutorial ======================================= This tutorial will show you how to write a simple unit test and run it with the Gradle build tool. The example in the tutorial has the [kotlin.test](https://kotlinlang.org/api/latest/kotlin.test/index.html) library under the hood and runs the test using JUnit. To get started, first download and install the latest version of [IntelliJ IDEA](https://www.jetbrains.com/idea/download/index.html). Add dependencies ---------------- 1. Open a Kotlin project in IntelliJ IDEA. If you don't already have a project, [create one](jvm-get-started#create-an-application). 2. Open the `build.gradle(.kts)` file and add the following dependency to the Gradle configuration. This dependency will allow you to work with `kotlin.test` and `JUnit`: ``` dependencies { // Other dependencies. testImplementation(kotlin("test")) } ``` ``` dependencies { // Other dependencies. testImplementation 'org.jetbrains.kotlin:kotlin-test' } ``` 3. Add the `test` task to the `build.gradle(.kts)` file: ``` tasks.test { useJUnitPlatform() } ``` ``` test { useJUnitPlatform() } ``` Add the code to test it ----------------------- 1. Open the `main.kt` file in `src/main/kotlin`. The `src` directory contains Kotlin source files and resources. The `main.kt` file contains sample code that will print `Hello, World!`. 2. Create the `Sample` class with the `sum()` function that adds two integers together: ``` class Sample() { fun sum(a: Int, b: Int): Int { return a + b } } ``` Create a test ------------- 1. In IntelliJ IDEA, select **Code** | **Generate** | **Test...** for the `Sample` class. ![Create a test](https://kotlinlang.org/docs/images/create-test.png "Create a test") 2. Specify the name of the test class. For example, `SampleTest`. IntelliJ IDEA creates the `SampleTest.kt` file in the `test` directory. This directory contains Kotlin test source files and resources. 3. Add the test code for the `sum()` function in `SampleTest.kt`: * Define the test `testSum()` function using the [@Test annotation](https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/-test/index.html). * Check that the `sum()` function returns the expected value by using the [assertEquals()](https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/assert-equals.html) function. ``` import kotlin.test.Test import kotlin.test.assertEquals internal class SampleTest { private val testSample: Sample = Sample() @Test fun testSum() { val expected = 42 assertEquals(expected, testSample.sum(40, 2)) } } ``` Run a test ---------- 1. Run the test using the gutter icon. ![Run the test](https://kotlinlang.org/docs/images/run-test.png "Run the test") 2. Check the result in the **Run** tool window: ![Check the test result. The test passed successfully](https://kotlinlang.org/docs/images/check-the-result.png "Check the test result. The test passed successfully")The test function was executed successfully. 3. Make sure that the test works correctly by changing the `expected` variable value to 43: ``` @Test fun testSum() { val expected = 43 assertEquals(expected, classForTesting.sum(40, 2)) } ``` 4. Run the test again and check the result: ![Check the test result. The test has been failed](https://kotlinlang.org/docs/images/check-the-result-2.png "Check the test result. The test has been failed")The test execution failed. What's next ----------- Once you've finished your first test, you can: * Try to write another test using other [kotlin.test](https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/) functions. For example, you could use the [`assertNotEquals()`](https://kotlinlang.org/api/latest/kotlin.test/kotlin.test/assert-not-equals.html) function. * [Create your first application](jvm-spring-boot-restful) with Kotlin and Spring Boot. * Watch [these video tutorials](https://www.youtube.com/playlist?list=PL6gx4Cwl9DGDPsneZWaOFg0H2wsundyGr) on YouTube, which demonstrate how to use Spring Boot with Kotlin and JUnit 5. Last modified: 10 January 2023 [Create a RESTful web service with a database using Spring Boot – tutorial](jvm-spring-boot-restful) [Mixing Java and Kotlin in one project – tutorial](mixing-java-kotlin-intellij) kotlin Kotlin/JS dead code elimination Kotlin/JS dead code elimination =============================== The Kotlin/JS Gradle plugin includes a *[dead code elimination](https://wikipedia.org/wiki/Dead_code_elimination)* (*DCE*) tool. Dead code elimination is often also called *tree shaking*. It reduces the size or the resulting JavaScript code by removing unused properties, functions, and classes. Unused declarations can appear in cases like: * A function is inlined and never gets called directly (which happens always except for a few situations). * A module uses a shared library. Without DCE, parts of the library that you don't use are still included in the resulting bundle. For example, the Kotlin standard library contains functions for manipulating lists, arrays, char sequences, adapters for DOM, and so on. All of this functionality would require about 1.3 MB as a JavaScript file. A simple "Hello, world" application only requires console routines, which is only few kilobytes for the entire file. The Kotlin/JS Gradle plugin handles DCE automatically when you build a **production bundle**, for example by using the `browserProductionWebpack` task. **Development bundling** tasks (like `browserDevelopmentWebpack`) don't include DCE. Exclude declarations from DCE ----------------------------- Sometimes you may need to keep a function or a class in the resulting JavaScript code even if you don't use it in your module, for example, if you're going to use it in the client JavaScript code. To keep certain declarations from elimination, add the `dceTask` block to your Gradle build script and list the declarations as arguments of the `keep` function. An argument must be the declaration's fully qualified name with the module name as a prefix: `moduleName.dot.separated.package.name.declarationName` ``` kotlin { js { browser { dceTask { keep("myKotlinJSModule.org.example.getName", "myKotlinJSModule.org.example.User" ) } binaries.executable() } } } ``` If you want to keep a whole package or module from elimination, you can use its fully qualified name as it appears in the generated JavaScript code. Disable DCE ----------- To turn off DCE completely, use the `devMode` option in the `dceTask`: ``` kotlin { js { browser { dceTask { dceOptions.devMode = true } } binaries.executable() } } ``` Last modified: 10 January 2023 [Run tests in Kotlin/JS](js-running-tests) [Kotlin/JS IR compiler](js-ir-compiler) kotlin Retrieve single elements Retrieve single elements ======================== Kotlin collections provide a set of functions for retrieving single elements from collections. Functions described on this page apply to both lists and sets. As the [definition of list](collections-overview) says, a list is an ordered collection. Hence, every element of a list has its position that you can use for referring. In addition to functions described on this page, lists offer a wider set of ways to retrieve and search for elements by indices. For more details, see [List-specific operations](list-operations). In turn, set is not an ordered collection by [definition](collections-overview). However, the Kotlin `Set` stores elements in certain orders. These can be the order of insertion (in `LinkedHashSet`), natural sorting order (in `SortedSet`), or another order. The order of a set of elements can also be unknown. In such cases, the elements are still ordered somehow, so the functions that rely on the element positions still return their results. However, such results are unpredictable to the caller unless they know the specific implementation of `Set` used. Retrieve by position -------------------- For retrieving an element at a specific position, there is the function [`elementAt()`](../api/latest/jvm/stdlib/kotlin.collections/element-at). Call it with the integer number as an argument, and you'll receive the collection element at the given position. The first element has the position `0`, and the last one is `(size - 1)`. `elementAt()` is useful for collections that do not provide indexed access, or are not statically known to provide one. In case of `List`, it's more idiomatic to use [indexed access operator](list-operations#retrieve-elements-by-index) (`get()` or `[]`). ``` fun main() { //sampleStart val numbers = linkedSetOf("one", "two", "three", "four", "five") println(numbers.elementAt(3)) val numbersSortedSet = sortedSetOf("one", "two", "three", "four") println(numbersSortedSet.elementAt(0)) // elements are stored in the ascending order //sampleEnd } ``` There are also useful aliases for retrieving the first and the last element of the collection: [`first()`](../api/latest/jvm/stdlib/kotlin.collections/first) and [`last()`](../api/latest/jvm/stdlib/kotlin.collections/last). ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five") println(numbers.first()) println(numbers.last()) //sampleEnd } ``` To avoid exceptions when retrieving element with non-existing positions, use safe variations of `elementAt()`: * [`elementAtOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/element-at-or-null) returns null when the specified position is out of the collection bounds. * [`elementAtOrElse()`](../api/latest/jvm/stdlib/kotlin.collections/element-at-or-else) additionally takes a lambda function that maps an `Int` argument to an instance of the collection element type. When called with an out-of-bounds position, the `elementAtOrElse()` returns the result of the lambda on the given value. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five") println(numbers.elementAtOrNull(5)) println(numbers.elementAtOrElse(5) { index -> "The value for index $index is undefined"}) //sampleEnd } ``` Retrieve by condition --------------------- Functions [`first()`](../api/latest/jvm/stdlib/kotlin.collections/first) and [`last()`](../api/latest/jvm/stdlib/kotlin.collections/last) also let you search a collection for elements matching a given predicate. When you call `first()` with a predicate that tests a collection element, you'll receive the first element on which the predicate yields `true`. In turn, `last()` with a predicate returns the last element matching it. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.first { it.length > 3 }) println(numbers.last { it.startsWith("f") }) //sampleEnd } ``` If no elements match the predicate, both functions throw exceptions. To avoid them, use [`firstOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/first-or-null) and [`lastOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/last-or-null) instead: they return `null` if no matching elements are found. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.firstOrNull { it.length > 6 }) //sampleEnd } ``` Use the aliases if their names suit your situation better: * [`find()`](../api/latest/jvm/stdlib/kotlin.collections/find) instead of `firstOrNull()` * [`findLast()`](../api/latest/jvm/stdlib/kotlin.collections/find-last) instead of `lastOrNull()` ``` fun main() { //sampleStart val numbers = listOf(1, 2, 3, 4) println(numbers.find { it % 2 == 0 }) println(numbers.findLast { it % 2 == 0 }) //sampleEnd } ``` Retrieve with selector ---------------------- If you need to map the collection before retrieving the element, there is a function [`firstNotNullOf()`](../api/latest/jvm/stdlib/kotlin.collections/first-not-null-of). It combines 2 actions: * Maps the collection with the selector function * Returns the first non-null value in the result `firstNotNullOf()` throws the `NoSuchElementException` if the resulting collection doesn't have a non-null element. Use the counterpart [`firstNotNullOfOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/first-not-null-of-or-null) to return null in this case. ``` fun main() { //sampleStart val list = listOf<Any>(0, "true", false) // Converts each element to string and returns the first one that has required length val longEnough = list.firstNotNullOf { item -> item.toString().takeIf { it.length >= 4 } } println(longEnough) //sampleEnd } ``` Random element -------------- If you need to retrieve an arbitrary element of a collection, call the [`random()`](../api/latest/jvm/stdlib/kotlin.collections/random) function. You can call it without arguments or with a [`Random`](../api/latest/jvm/stdlib/kotlin.random/-random/index) object as a source of the randomness. ``` fun main() { //sampleStart val numbers = listOf(1, 2, 3, 4) println(numbers.random()) //sampleEnd } ``` On empty collections, `random()` throws an exception. To receive `null` instead, use [`randomOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/random-or-null) Check element existence ----------------------- To check the presence of an element in a collection, use the [`contains()`](../api/latest/jvm/stdlib/kotlin.collections/contains) function. It returns `true` if there is a collection element that `equals()` the function argument. You can call `contains()` in the operator form with the `in` keyword. To check the presence of multiple instances together at once, call [`containsAll()`](../api/latest/jvm/stdlib/kotlin.collections/contains-all) with a collection of these instances as an argument. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.contains("four")) println("zero" in numbers) println(numbers.containsAll(listOf("four", "two"))) println(numbers.containsAll(listOf("one", "zero"))) //sampleEnd } ``` Additionally, you can check if the collection contains any elements by calling [`isEmpty()`](../api/latest/jvm/stdlib/kotlin.collections/is-empty) or [`isNotEmpty()`](../api/latest/jvm/stdlib/kotlin.collections/is-not-empty). ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four", "five", "six") println(numbers.isEmpty()) println(numbers.isNotEmpty()) val empty = emptyList<String>() println(empty.isEmpty()) println(empty.isNotEmpty()) //sampleEnd } ``` Last modified: 10 January 2023 [Retrieve collection parts](collection-parts) [Ordering](collection-ordering) kotlin KSP quickstart KSP quickstart ============== For a quick start, you can create your own processor or get a [sample one](https://github.com/google/ksp/tree/main/examples/playground). Create a processor of your own ------------------------------ 1. Create an empty gradle project. 2. Specify version `1.8.0` of the Kotlin plugin in the root project for use in other project modules: ``` plugins { kotlin("jvm") version "1.8.0" apply false } buildscript { dependencies { classpath(kotlin("gradle-plugin", version = "1.8.0")) } } ``` ``` plugins { id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false } buildscript { dependencies { classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0' } } ``` 3. Add a module for hosting the processor. 4. In the module's build script, apply Kotlin plugin and add the KSP API to the `dependencies` block. ``` plugins { kotlin("jvm") } repositories { mavenCentral() } dependencies { implementation("com.google.devtools.ksp:symbol-processing-api:1.8.0-1.0.8") } ``` ``` plugins { id 'org.jetbrains.kotlin.jvm' version '1.8.0' } repositories { mavenCentral() } dependencies { implementation 'com.google.devtools.ksp:symbol-processing-api:1.8.0-1.0.8' } ``` 5. You'll need to implement [`com.google.devtools.ksp.processing.SymbolProcessor`](https://github.com/google/ksp/tree/main/api/src/main/kotlin/com/google/devtools/ksp/processing/SymbolProcessor.kt) and [`com.google.devtools.ksp.processing.SymbolProcessorProvider`](https://github.com/google/ksp/tree/main/api/src/main/kotlin/com/google/devtools/ksp/processing/SymbolProcessorProvider.kt). Your implementation of `SymbolProcessorProvider` will be loaded as a service to instantiate the `SymbolProcessor` you implement. Note the following: * Implement [`SymbolProcessorProvider.create()`](https://github.com/google/ksp/blob/master/api/src/main/kotlin/com/google/devtools/ksp/processing/SymbolProcessorProvider.kt) to create a `SymbolProcessor`. Pass dependencies that your processor needs (such as `CodeGenerator`, processor options) through the parameters of `SymbolProcessorProvider.create()`. * Your main logic should be in the [`SymbolProcessor.process()`](https://github.com/google/ksp/blob/master/api/src/main/kotlin/com/google/devtools/ksp/processing/SymbolProcessor.kt) method. * Use `resolver.getSymbolsWithAnnotation()` to get the symbols you want to process, given the fully-qualified name of an annotation. * A common use case for KSP is to implement a customized visitor (interface `com.google.devtools.ksp.symbol.KSVisitor`) for operating on symbols. A simple template visitor is `com.google.devtools.ksp.symbol.KSDefaultVisitor`. * For sample implementations of the `SymbolProcessorProvider` and `SymbolProcessor` interfaces, see the following files in the sample project. + `src/main/kotlin/BuilderProcessor.kt` + `src/main/kotlin/TestProcessor.kt` * After writing your own processor, register your processor provider to the package by including its fully-qualified name in `resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider`. Use your own processor in a project ----------------------------------- 1. Create another module that contains a workload where you want to try out your processor. ``` pluginManagement { repositories { gradlePluginPortal() } } ``` ``` pluginManagement { repositories { gradlePluginPortal() } } ``` 2. In the module's build script, apply the `com.google.devtools.ksp` plugin with the specified version and add your processor to the list of dependencies. ``` plugins { id("com.google.devtools.ksp") version "1.8.0-1.0.8" } dependencies { implementation(kotlin("stdlib-jdk8")) implementation(project(":test-processor")) ksp(project(":test-processor")) } ``` ``` plugins { id 'com.google.devtools.ksp' version '1.8.0-1.0.8' } dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version' implementation project(':test-processor') ksp project(':test-processor') } ``` 3. Run `./gradlew build`. You can find the generated code under `build/generated/source/ksp`. Here's a sample build script to apply the KSP plugin to a workload: ``` plugins { id("com.google.devtools.ksp") version "1.8.0-1.0.8" kotlin("jvm") } repositories { mavenCentral() } dependencies { implementation(kotlin("stdlib-jdk8")) implementation(project(":test-processor")) ksp(project(":test-processor")) } ``` ``` plugins { id 'com.google.devtools.ksp' version '1.8.0-1.0.8' id 'org.jetbrains.kotlin.jvm' version '1.8.0' } repositories { mavenCentral() } dependencies { implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.8.0' implementation project(':test-processor') ksp project(':test-processor') } ``` Pass options to processors -------------------------- Processor options in `SymbolProcessorEnvironment.options` are specified in gradle build scripts: ``` ksp { arg("option1", "value1") arg("option2", "value2") ... } ``` Make IDE aware of generated code -------------------------------- By default, IntelliJ IDEA or other IDEs don't know about the generated code. So it will mark references to generated symbols unresolvable. To make an IDE be able to reason about the generated symbols, mark the following paths as generated source roots: ``` build/generated/ksp/main/kotlin/ build/generated/ksp/main/java/ ``` If your IDE supports resource directories, also mark the following one: ``` build/generated/ksp/main/resources/ ``` It may also be necessary to configure these directories in your KSP consumer module's build script: ``` kotlin { sourceSets.main { kotlin.srcDir("build/generated/ksp/main/kotlin") } sourceSets.test { kotlin.srcDir("build/generated/ksp/test/kotlin") } } ``` ``` kotlin { sourceSets { main.kotlin.srcDirs += 'build/generated/ksp/main/kotlin' test.kotlin.srcDirs += 'build/generated/ksp/test/kotlin' } } ``` If you are using IntelliJ IDEA and KSP in a Gradle plugin then the above snippet will give the following warning: ``` Execution optimizations have been disabled for task ':publishPluginJar' to ensure correctness due to the following reasons: Gradle detected a problem with the following location: '../build/generated/ksp/main/kotlin'. Reason: Task ':publishPluginJar' uses this output of task ':kspKotlin' without declaring an explicit or implicit dependency. ``` In this case, use the following script instead: ``` plugins { // ... idea } idea { module { // Not using += due to https://github.com/gradle/gradle/issues/8749 sourceDirs = sourceDirs + file("build/generated/ksp/main/kotlin") // or tasks["kspKotlin"].destination testSourceDirs = testSourceDirs + file("build/generated/ksp/test/kotlin") generatedSourceDirs = generatedSourceDirs + file("build/generated/ksp/main/kotlin") + file("build/generated/ksp/test/kotlin") } } ``` ``` plugins { // ... id 'idea' } idea { module { // Not using += due to https://github.com/gradle/gradle/issues/8749 sourceDirs = sourceDirs + file('build/generated/ksp/main/kotlin') // or tasks["kspKotlin"].destination testSourceDirs = testSourceDirs + file('build/generated/ksp/test/kotlin') generatedSourceDirs = generatedSourceDirs + file('build/generated/ksp/main/kotlin') + file('build/generated/ksp/test/kotlin') } } ``` Last modified: 10 January 2023 [Kotlin Symbol Processing API](ksp-overview) [Why KSP](ksp-why-ksp)
programming_docs
kotlin Calling Kotlin from Java Calling Kotlin from Java ======================== Kotlin code can be easily called from Java. For example, instances of a Kotlin class can be seamlessly created and operated in Java methods. However, there are certain differences between Java and Kotlin that require attention when integrating Kotlin code into Java. On this page, we'll describe the ways to tailor the interop of your Kotlin code with its Java clients. Properties ---------- A Kotlin property is compiled to the following Java elements: * a getter method, with the name calculated by prepending the `get` prefix * a setter method, with the name calculated by prepending the `set` prefix (only for `var` properties) * a private field, with the same name as the property name (only for properties with backing fields) For example, `var firstName: String` compiles to the following Java declarations: ``` private String firstName; public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } ``` If the name of the property starts with `is`, a different name mapping rule is used: the name of the getter will be the same as the property name, and the name of the setter will be obtained by replacing `is` with `set`. For example, for a property `isOpen`, the getter will be called `isOpen()` and the setter will be called `setOpen()`. This rule applies for properties of any type, not just `Boolean`. Package-level functions ----------------------- All the functions and properties declared in a file `app.kt` inside a package `org.example`, including extension functions, are compiled into static methods of a Java class named `org.example.AppKt`. ``` // app.kt package org.example class Util fun getTime() { /*...*/ } ``` ``` // Java new org.example.Util(); org.example.AppKt.getTime(); ``` To set a custom name to the generated Java class, use the `@JvmName` annotation: ``` @file:JvmName("DemoUtils") package org.example class Util fun getTime() { /*...*/ } ``` ``` // Java new org.example.Util(); org.example.DemoUtils.getTime(); ``` Having multiple files with the same generated Java class name (the same package and the same name or the same [`@JvmName`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index) annotation) is normally an error. However, the compiler can generate a single Java facade class which has the specified name and contains all the declarations from all the files which have that name. To enable the generation of such a facade, use the [`@JvmMultifileClass`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-multifile-class/index) annotation in all such files. ``` // oldutils.kt @file:JvmName("Utils") @file:JvmMultifileClass package org.example fun getTime() { /*...*/ } ``` ``` // newutils.kt @file:JvmName("Utils") @file:JvmMultifileClass package org.example fun getDate() { /*...*/ } ``` ``` // Java org.example.Utils.getTime(); org.example.Utils.getDate(); ``` Instance fields --------------- If you need to expose a Kotlin property as a field in Java, annotate it with the [`@JvmField`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-field/index) annotation. The field will have the same visibility as the underlying property. You can annotate a property with `@JvmField` if it: * has a backing field * is not private * does not have `open`, `override` or `const` modifiers * is not a delegated property ``` class User(id: String) { @JvmField val ID = id } ``` ``` // Java class JavaClient { public String getID(User user) { return user.ID; } } ``` [Late-Initialized](properties#late-initialized-properties-and-variables) properties are also exposed as fields. The visibility of the field will be the same as the visibility of `lateinit` property setter. Static fields ------------- Kotlin properties declared in a named object or a companion object will have static backing fields either in that named object or in the class containing the companion object. Usually these fields are private but they can be exposed in one of the following ways: * [`@JvmField`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-field/index) annotation * `lateinit` modifier * `const` modifier Annotating such a property with `@JvmField` makes it a static field with the same visibility as the property itself. ``` class Key(val value: Int) { companion object { @JvmField val COMPARATOR: Comparator<Key> = compareBy<Key> { it.value } } } ``` ``` // Java Key.COMPARATOR.compare(key1, key2); // public static final field in Key class ``` A [late-initialized](properties#late-initialized-properties-and-variables) property in an object or a companion object has a static backing field with the same visibility as the property setter. ``` object Singleton { lateinit var provider: Provider } ``` ``` // Java Singleton.provider = new Provider(); // public static non-final field in Singleton class ``` Properties declared as `const` (in classes as well as at the top level) are turned into static fields in Java: ``` // file example.kt object Obj { const val CONST = 1 } class C { companion object { const val VERSION = 9 } } const val MAX = 239 ``` In Java: ``` int constant = Obj.CONST; int max = ExampleKt.MAX; int version = C.VERSION; ``` Static methods -------------- As mentioned above, Kotlin represents package-level functions as static methods. Kotlin can also generate static methods for functions defined in named objects or companion objects if you annotate those functions as [`@JvmStatic`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-static/index). If you use this annotation, the compiler will generate both a static method in the enclosing class of the object and an instance method in the object itself. For example: ``` class C { companion object { @JvmStatic fun callStatic() {} fun callNonStatic() {} } } ``` Now, `callStatic()` is static in Java while `callNonStatic()` is not: ``` C.callStatic(); // works fine C.callNonStatic(); // error: not a static method C.Companion.callStatic(); // instance method remains C.Companion.callNonStatic(); // the only way it works ``` Same for named objects: ``` object Obj { @JvmStatic fun callStatic() {} fun callNonStatic() {} } ``` In Java: ``` Obj.callStatic(); // works fine Obj.callNonStatic(); // error Obj.INSTANCE.callNonStatic(); // works, a call through the singleton instance Obj.INSTANCE.callStatic(); // works too ``` Starting from Kotlin 1.3, `@JvmStatic` applies to functions defined in companion objects of interfaces as well. Such functions compile to static methods in interfaces. Note that static method in interfaces were introduced in Java 1.8, so be sure to use the corresponding targets. ``` interface ChatBot { companion object { @JvmStatic fun greet(username: String) { println("Hello, $username") } } } ``` `@JvmStatic` annotation can also be applied on a property of an object or a companion object making its getter and setter methods static members in that object or the class containing the companion object. Default methods in interfaces ----------------------------- Starting from JDK 1.8, interfaces in Java can contain [default methods](https://docs.oracle.com/javase/tutorial/java/IandI/defaultmethods.html). To make all non-abstract members of Kotlin interfaces default for the Java classes implementing them, compile the Kotlin code with the `-Xjvm-default=all` compiler option. Here is an example of a Kotlin interface with a default method: ``` // compile with -Xjvm-default=all interface Robot { fun move() { println("~walking~") } // will be default in the Java interface fun speak(): Unit } ``` The default implementation is available for Java classes implementing the interface. ``` //Java implementation public class C3PO implements Robot { // move() implementation from Robot is available implicitly @Override public void speak() { System.out.println("I beg your pardon, sir"); } } ``` ``` C3PO c3po = new C3PO(); c3po.move(); // default implementation from the Robot interface c3po.speak(); ``` Implementations of the interface can override default methods. ``` //Java public class BB8 implements Robot { //own implementation of the default method @Override public void move() { System.out.println("~rolling~"); } @Override public void speak() { System.out.println("Beep-beep"); } } ``` ### Compatibility modes for default methods If there are clients that use your Kotlin interfaces compiled without the `-Xjvm-default=all` option, then they may be binary-incompatible with the code compiled with this option. To avoid breaking the compatibility with such clients, use the `-Xjvm-default=all` mode and mark interfaces with the [`@JvmDefaultWithCompatibility`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-default-with-compatibility/index) annotation. This allows you to add this annotation to all interfaces in the public API once, and you won't need to use any annotations for new non-public code. Learn more about compatibility modes: #### disable Default behavior. Do not generate JVM default methods and prohibit `@JvmDefault` annotation usage. #### all Generate JVM default methods for all interface declarations with bodies in the module. Do not generate [`DefaultImpls`](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/) stubs for interface declarations with bodies, which are generated by default in the `disable` mode. If interface inherits a method with body from an interface compiled in the `disable` mode and doesn't override it, then a `DefaultImpls` stub will be generated for it. **Breaks binary compatibility** if some client code relies on the presence of `DefaultImpls` classes. #### all-compatibility In addition to the `all` mode, generate compatibility stubs in the [`DefaultImpls`](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/) classes. Compatibility stubs could be useful for library and runtime authors to keep backward binary compatibility for existing clients compiled against previous library versions. `all` and `all-compatibility` modes are changing the library ABI surface that clients will use after the recompilation of the library. In that sense, clients might be incompatible with previous library versions. This usually means that you need a proper library versioning, for example, major version increase in SemVer. The compiler generates all the members of `DefaultImpls` with the `@Deprecated` annotation: you shouldn't use these members in Java code, because the compiler generates them only for compatibility purposes. In case of inheritance from a Kotlin interface compiled in `all` or `all-compatibility` modes, `DefaultImpls` compatibility stubs will invoke the default method of the interface with standard JVM runtime resolution semantics. Perform additional compatibility checks for classes inheriting generic interfaces where in some cases additional implicit method with specialized signatures was generated in the `disable` mode: unlike in the `disable` mode, the compiler will report an error if you don't override such method explicitly and don't annotate the class with `@JvmDefaultWithoutCompatibility` (see [this YouTrack issue](https://youtrack.jetbrains.com/issue/KT-39603) for more details). Visibility ---------- The Kotlin visibility modifiers map to Java in the following way: * `private` members are compiled to `private` members * `private` top-level declarations are compiled to package-local declarations * `protected` remains `protected` (note that Java allows accessing protected members from other classes in the same package and Kotlin doesn't, so Java classes will have broader access to the code) * `internal` declarations become `public` in Java. Members of `internal` classes go through name mangling, to make it harder to accidentally use them from Java and to allow overloading for members with the same signature that don't see each other according to Kotlin rules * `public` remains `public` KClass ------ Sometimes you need to call a Kotlin method with a parameter of type `KClass`. There is no automatic conversion from `Class` to `KClass`, so you have to do it manually by invoking the equivalent of the `Class<T>.kotlin` extension property: ``` kotlin.jvm.JvmClassMappingKt.getKotlinClass(MainView.class) ``` Handling signature clashes with @JvmName ---------------------------------------- Sometimes we have a named function in Kotlin, for which we need a different JVM name in the bytecode. The most prominent example happens due to *type erasure*: ``` fun List<String>.filterValid(): List<String> fun List<Int>.filterValid(): List<Int> ``` These two functions can not be defined side-by-side, because their JVM signatures are the same: `filterValid(Ljava/util/List;)Ljava/util/List;`. If we really want them to have the same name in Kotlin, we can annotate one (or both) of them with [`@JvmName`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-name/index) and specify a different name as an argument: ``` fun List<String>.filterValid(): List<String> @JvmName("filterValidInt") fun List<Int>.filterValid(): List<Int> ``` From Kotlin they will be accessible by the same name `filterValid`, but from Java it will be `filterValid` and `filterValidInt`. The same trick applies when we need to have a property `x` alongside with a function `getX()`: ``` val x: Int @JvmName("getX_prop") get() = 15 fun getX() = 10 ``` To change the names of generated accessor methods for properties without explicitly implemented getters and setters, you can use `@get:JvmName` and `@set:JvmName`: ``` @get:JvmName("x") @set:JvmName("changeX") var x: Int = 23 ``` Overloads generation -------------------- Normally, if you write a Kotlin function with default parameter values, it will be visible in Java only as a full signature, with all parameters present. If you wish to expose multiple overloads to Java callers, you can use the [`@JvmOverloads`](../api/latest/jvm/stdlib/kotlin.jvm/-jvm-overloads/index) annotation. The annotation also works for constructors, static methods, and so on. It can't be used on abstract methods, including methods defined in interfaces. ``` class Circle @JvmOverloads constructor(centerX: Int, centerY: Int, radius: Double = 1.0) { @JvmOverloads fun draw(label: String, lineWidth: Int = 1, color: String = "red") { /*...*/ } } ``` For every parameter with a default value, this will generate one additional overload, which has this parameter and all parameters to the right of it in the parameter list removed. In this example, the following will be generated: ``` // Constructors: Circle(int centerX, int centerY, double radius) Circle(int centerX, int centerY) // Methods void draw(String label, int lineWidth, String color) { } void draw(String label, int lineWidth) { } void draw(String label) { } ``` Note that, as described in [Secondary constructors](classes#secondary-constructors), if a class has default values for all constructor parameters, a public constructor with no arguments will be generated for it. This works even if the `@JvmOverloads` annotation is not specified. Checked exceptions ------------------ Kotlin does not have checked exceptions. So, normally the Java signatures of Kotlin functions do not declare exceptions thrown. Thus, if you have a function in Kotlin like this: ``` // example.kt package demo fun writeToFile() { /*...*/ throw IOException() } ``` And you want to call it from Java and catch the exception: ``` // Java try { demo.Example.writeToFile(); } catch (IOException e) { // error: writeToFile() does not declare IOException in the throws list // ... } ``` You get an error message from the Java compiler, because `writeToFile()` does not declare `IOException`. To work around this problem, use the [`@Throws`](../api/latest/jvm/stdlib/kotlin/-throws/index) annotation in Kotlin: ``` @Throws(IOException::class) fun writeToFile() { /*...*/ throw IOException() } ``` Null-safety ----------- When calling Kotlin functions from Java, nobody prevents us from passing `null` as a non-null parameter. That's why Kotlin generates runtime checks for all public functions that expect non-nulls. This way we get a `NullPointerException` in the Java code immediately. Variant generics ---------------- When Kotlin classes make use of [declaration-site variance](generics#declaration-site-variance), there are two options of how their usages are seen from the Java code. For example, imagine you have the following class and two functions that use it: ``` class Box<out T>(val value: T) interface Base class Derived : Base fun boxDerived(value: Derived): Box<Derived> = Box(value) fun unboxBase(box: Box<Base>): Base = box.value ``` A naive way of translating these functions into Java would be this: ``` Box<Derived> boxDerived(Derived value) { ... } Base unboxBase(Box<Base> box) { ... } ``` The problem is that in Kotlin you can write `unboxBase(boxDerived(Derived()))` but in Java that would be impossible because in Java the class `Box` is *invariant* in its parameter `T`, and thus `Box<Derived>` is not a subtype of `Box<Base>`. To make this work in Java, you would have to define `unboxBase` as follows: ``` Base unboxBase(Box<? extends Base> box) { ... } ``` This declaration uses Java's *wildcards types* (`? extends Base`) to emulate declaration-site variance through use-site variance, because it is all Java has. To make Kotlin APIs work in Java, the compiler generates `Box<Super>` as `Box<? extends Super>` for covariantly defined `Box` (or `Foo<? super Bar>` for contravariantly defined `Foo`) when it appears *as a parameter*. When it's a return value, wildcards are not generated, because otherwise Java clients will have to deal with them (and it's against the common Java coding style). Therefore, the functions from our example are actually translated as follows: ``` // return type - no wildcards Box<Derived> boxDerived(Derived value) { ... } // parameter - wildcards Base unboxBase(Box<? extends Base> box) { ... } ``` If you need wildcards where they are not generated by default, use the `@JvmWildcard` annotation: ``` fun boxDerived(value: Derived): Box<@JvmWildcard Derived> = Box(value) // is translated to // Box<? extends Derived> boxDerived(Derived value) { ... } ``` In the opposite case, if you don't need wildcards where they are generated, use `@JvmSuppressWildcards`: ``` fun unboxBase(box: Box<@JvmSuppressWildcards Base>): Base = box.value // is translated to // Base unboxBase(Box<Base> box) { ... } ``` ### Translation of type Nothing The type [`Nothing`](exceptions#the-nothing-type) is special, because it has no natural counterpart in Java. Indeed, every Java reference type, including `java.lang.Void`, accepts `null` as a value, and `Nothing` doesn't accept even that. So, this type cannot be accurately represented in the Java world. This is why Kotlin generates a raw type where an argument of type `Nothing` is used: ``` fun emptyList(): List<Nothing> = listOf() // is translated to // List emptyList() { ... } ``` Last modified: 10 January 2023 [Calling Java from Kotlin](java-interop) [Create a RESTful web service with a database using Spring Boot – tutorial](jvm-spring-boot-restful) kotlin Type aliases Type aliases ============ Type aliases provide alternative names for existing types. If the type name is too long you can introduce a different shorter name and use the new one instead. It's useful to shorten long generic types. For instance, it's often tempting to shrink collection types: ``` typealias NodeSet = Set<Network.Node> typealias FileTable<K> = MutableMap<K, MutableList<File>> ``` You can provide different aliases for function types: ``` typealias MyHandler = (Int, String, Any) -> Unit typealias Predicate<T> = (T) -> Boolean ``` You can have new names for inner and nested classes: ``` class A { inner class Inner } class B { inner class Inner } typealias AInner = A.Inner typealias BInner = B.Inner ``` Type aliases do not introduce new types. They are equivalent to the corresponding underlying types. When you add `typealias Predicate<T>` and use `Predicate<Int>` in your code, the Kotlin compiler always expands it to `(Int) -> Boolean`. Thus you can pass a variable of your type whenever a general function type is required and vice versa: ``` typealias Predicate<T> = (T) -> Boolean fun foo(p: Predicate<Int>) = p(42) fun main() { val f: (Int) -> Boolean = { it > 0 } println(foo(f)) // prints "true" val p: Predicate<Int> = { it > 0 } println(listOf(1, -2).filter(p)) // prints "[1]" } ``` Last modified: 10 January 2023 [Delegated properties](delegated-properties) [Functions](functions)
programming_docs
kotlin High-order functions and lambdas High-order functions and lambdas ================================ Kotlin functions are [first-class](https://en.wikipedia.org/wiki/First-class_function), which means they can be stored in variables and data structures, and can be passed as arguments to and returned from other [higher-order functions](#higher-order-functions). You can perform any operations on functions that are possible for other non-function values. To facilitate this, Kotlin, as a statically typed programming language, uses a family of [function types](#function-types) to represent functions, and provides a set of specialized language constructs, such as [lambda expressions](#lambda-expressions-and-anonymous-functions). Higher-order functions ---------------------- A higher-order function is a function that takes functions as parameters, or returns a function. A good example of a higher-order function is the [functional programming idiom `fold`](https://en.wikipedia.org/wiki/Fold_(higher-order_function)) for collections. It takes an initial accumulator value and a combining function and builds its return value by consecutively combining the current accumulator value with each collection element, replacing the accumulator value each time: ``` fun <T, R> Collection<T>.fold( initial: R, combine: (acc: R, nextElement: T) -> R ): R { var accumulator: R = initial for (element: T in this) { accumulator = combine(accumulator, element) } return accumulator } ``` In the code above, the `combine` parameter has the [function type](#function-types) `(R, T) -> R`, so it accepts a function that takes two arguments of types `R` and `T` and returns a value of type `R`. It is [invoked](#invoking-a-function-type-instance) inside the `for` loop, and the return value is then assigned to `accumulator`. To call `fold`, you need to pass an [instance of the function type](#instantiating-a-function-type) to it as an argument, and lambda expressions ([described in more detail below](#lambda-expressions-and-anonymous-functions)) are widely used for this purpose at higher-order function call sites: ``` fun main() { //sampleStart val items = listOf(1, 2, 3, 4, 5) // Lambdas are code blocks enclosed in curly braces. items.fold(0, { // When a lambda has parameters, they go first, followed by '->' acc: Int, i: Int -> print("acc = $acc, i = $i, ") val result = acc + i println("result = $result") // The last expression in a lambda is considered the return value: result }) // Parameter types in a lambda are optional if they can be inferred: val joinedToString = items.fold("Elements:", { acc, i -> acc + " " + i }) // Function references can also be used for higher-order function calls: val product = items.fold(1, Int::times) //sampleEnd println("joinedToString = $joinedToString") println("product = $product") } ``` Function types -------------- Kotlin uses function types, such as `(Int) -> String`, for declarations that deal with functions: `val onClick: () -> Unit = ...`. These types have a special notation that corresponds to the signatures of the functions - their parameters and return values: * All function types have a parenthesized list of parameter types and a return type: `(A, B) -> C` denotes a type that represents functions that take two arguments of types `A` and `B` and return a value of type `C`. The list of parameter types may be empty, as in `() -> A`. The [`Unit` return type](functions#unit-returning-functions) cannot be omitted. * Function types can optionally have an additional *receiver* type, which is specified before the dot in the notation: the type `A.(B) -> C` represents functions that can be called on a receiver object `A` with a parameter `B` and return a value `C`. [Function literals with receiver](#function-literals-with-receiver) are often used along with these types. * [Suspending functions](coroutines-basics#extract-function-refactoring) belong to a special kind of function type that have a *suspend* modifier in their notation, such as `suspend () -> Unit` or `suspend A.(B) -> C`. The function type notation can optionally include names for the function parameters: `(x: Int, y: Int) -> Point`. These names can be used for documenting the meaning of the parameters. To specify that a function type is [nullable](null-safety#nullable-types-and-non-null-types), use parentheses as follows: `((Int, Int) -> Int)?`. Function types can also be combined using parentheses: `(Int) -> ((Int) -> Unit)`. You can also give a function type an alternative name by using [a type alias](type-aliases): ``` typealias ClickHandler = (Button, ClickEvent) -> Unit ``` ### Instantiating a function type There are several ways to obtain an instance of a function type: * Use a code block within a function literal, in one of the following forms: + a [lambda expression](#lambda-expressions-and-anonymous-functions): `{ a, b -> a + b }`, + an [anonymous function](#anonymous-functions): `fun(s: String): Int { return s.toIntOrNull() ?: 0 }`[Function literals with receiver](#function-literals-with-receiver) can be used as values of function types with receiver. * Use a callable reference to an existing declaration: + a top-level, local, member, or extension [function](reflection#function-references): `::isOdd`, `String::toInt`, + a top-level, member, or extension [property](reflection#property-references): `List<Int>::size`, + a [constructor](reflection#constructor-references): `::Regex`These include [bound callable references](reflection#bound-function-and-property-references) that point to a member of a particular instance: `foo::toString`. * Use instances of a custom class that implements a function type as an interface: ``` class IntTransformer: (Int) -> Int { override operator fun invoke(x: Int): Int = TODO() } val intFunction: (Int) -> Int = IntTransformer() ``` The compiler can infer the function types for variables if there is enough information: ``` val a = { i: Int -> i + 1 } // The inferred type is (Int) -> Int ``` *Non-literal* values of function types with and without a receiver are interchangeable, so the receiver can stand in for the first parameter, and vice versa. For instance, a value of type `(A, B) -> C` can be passed or assigned where a value of type `A.(B) -> C` is expected, and the other way around: ``` fun main() { //sampleStart val repeatFun: String.(Int) -> String = { times -> this.repeat(times) } val twoParameters: (String, Int) -> String = repeatFun // OK fun runTransformation(f: (String, Int) -> String): String { return f("hello", 3) } val result = runTransformation(repeatFun) // OK //sampleEnd println("result = $result") } ``` ### Invoking a function type instance A value of a function type can be invoked by using its [`invoke(...)` operator](operator-overloading#invoke-operator): `f.invoke(x)` or just `f(x)`. If the value has a receiver type, the receiver object should be passed as the first argument. Another way to invoke a value of a function type with receiver is to prepend it with the receiver object, as if the value were an [extension function](extensions): `1.foo(2)`. Example: ``` fun main() { //sampleStart val stringPlus: (String, String) -> String = String::plus val intPlus: Int.(Int) -> Int = Int::plus println(stringPlus.invoke("<-", "->")) println(stringPlus("Hello, ", "world!")) println(intPlus.invoke(1, 1)) println(intPlus(1, 2)) println(2.intPlus(3)) // extension-like call //sampleEnd } ``` ### Inline functions Sometimes it is beneficial to use [inline functions](inline-functions), which provide flexible control flow, for higher-order functions. Lambda expressions and anonymous functions ------------------------------------------ Lambda expressions and anonymous functions are *function literals*. Function literals are functions that are not declared but are passed immediately as an expression. Consider the following example: ``` max(strings, { a, b -> a.length < b.length }) ``` The function `max` is a higher-order function, as it takes a function value as its second argument. This second argument is an expression that is itself a function, called a function literal, which is equivalent to the following named function: ``` fun compare(a: String, b: String): Boolean = a.length < b.length ``` ### Lambda expression syntax The full syntactic form of lambda expressions is as follows: ``` val sum: (Int, Int) -> Int = { x: Int, y: Int -> x + y } ``` * A lambda expression is always surrounded by curly braces. * Parameter declarations in the full syntactic form go inside curly braces and have optional type annotations. * The body goes after the `->`. * If the inferred return type of the lambda is not `Unit`, the last (or possibly single) expression inside the lambda body is treated as the return value. If you leave all the optional annotations out, what's left looks like this: ``` val sum = { x: Int, y: Int -> x + y } ``` ### Passing trailing lambdas According to Kotlin convention, if the last parameter of a function is a function, then a lambda expression passed as the corresponding argument can be placed outside the parentheses: ``` val product = items.fold(1) { acc, e -> acc * e } ``` Such syntax is also known as *trailing lambda*. If the lambda is the only argument in that call, the parentheses can be omitted entirely: ``` run { println("...") } ``` ### it: implicit name of a single parameter It's very common for a lambda expression to have only one parameter. If the compiler can parse the signature without any parameters, the parameter does not need to be declared and `->` can be omitted. The parameter will be implicitly declared under the name `it`: ``` ints.filter { it > 0 } // this literal is of type '(it: Int) -> Boolean' ``` ### Returning a value from a lambda expression You can explicitly return a value from the lambda using the [qualified return](returns#return-to-labels) syntax. Otherwise, the value of the last expression is implicitly returned. Therefore, the two following snippets are equivalent: ``` ints.filter { val shouldFilter = it > 0 shouldFilter } ints.filter { val shouldFilter = it > 0 return@filter shouldFilter } ``` This convention, along with [passing a lambda expression outside of parentheses](#passing-trailing-lambdas), allows for [LINQ-style](https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/bb308959(v=msdn.10)) code: ``` strings.filter { it.length == 5 }.sortedBy { it }.map { it.uppercase() } ``` ### Underscore for unused variables If the lambda parameter is unused, you can place an underscore instead of its name: ``` map.forEach { (_, value) -> println("$value!") } ``` ### Destructuring in lambdas Destructuring in lambdas is described as a part of [destructuring declarations](destructuring-declarations#destructuring-in-lambdas). ### Anonymous functions The lambda expression syntax above is missing one thing – the ability to specify the function's return type. In most cases, this is unnecessary because the return type can be inferred automatically. However, if you do need to specify it explicitly, you can use an alternative syntax: an *anonymous function*. ``` fun(x: Int, y: Int): Int = x + y ``` An anonymous function looks very much like a regular function declaration, except its name is omitted. Its body can be either an expression (as shown above) or a block: ``` fun(x: Int, y: Int): Int { return x + y } ``` The parameters and the return type are specified in the same way as for regular functions, except the parameter types can be omitted if they can be inferred from the context: ``` ints.filter(fun(item) = item > 0) ``` The return type inference for anonymous functions works just like for normal functions: the return type is inferred automatically for anonymous functions with an expression body, but it has to be specified explicitly (or is assumed to be `Unit`) for anonymous functions with a block body. Another difference between lambda expressions and anonymous functions is the behavior of [non-local returns](inline-functions#non-local-returns). A `return` statement without a label always returns from the function declared with the `fun` keyword. This means that a `return` inside a lambda expression will return from the enclosing function, whereas a `return` inside an anonymous function will return from the anonymous function itself. ### Closures A lambda expression or anonymous function (as well as a [local function](functions#local-functions) and an [object expression](object-declarations#object-expressions)) can access its *closure*, which includes the variables declared in the outer scope. The variables captured in the closure can be modified in the lambda: ``` var sum = 0 ints.filter { it > 0 }.forEach { sum += it } print(sum) ``` ### Function literals with receiver [Function types](#function-types) with receiver, such as `A.(B) -> C`, can be instantiated with a special form of function literals – function literals with receiver. As mentioned above, Kotlin provides the ability [to call an instance](#invoking-a-function-type-instance) of a function type with receiver while providing the *receiver object*. Inside the body of the function literal, the receiver object passed to a call becomes an *implicit* `this`, so that you can access the members of that receiver object without any additional qualifiers, or access the receiver object using a [`this` expression](this-expressions). This behavior is similar to that of [extension functions](extensions), which also allow you to access the members of the receiver object inside the function body. Here is an example of a function literal with receiver along with its type, where `plus` is called on the receiver object: ``` val sum: Int.(Int) -> Int = { other -> plus(other) } ``` The anonymous function syntax allows you to specify the receiver type of a function literal directly. This can be useful if you need to declare a variable of a function type with receiver, and then to use it later. ``` val sum = fun Int.(other: Int): Int = this + other ``` Lambda expressions can be used as function literals with receiver when the receiver type can be inferred from the context. One of the most important examples of their usage is [type-safe builders](type-safe-builders): ``` class HTML { fun body() { ... } } fun html(init: HTML.() -> Unit): HTML { val html = HTML() // create the receiver object html.init() // pass the receiver object to the lambda return html } html { // lambda with receiver begins here body() // calling a method on the receiver object } ``` Last modified: 10 January 2023 [Functions](functions) [Inline functions](inline-functions) kotlin Arrays Arrays ====== Arrays in Kotlin are represented by the `Array` class. It has `get()` and `set()` functions that turn into `[]` by operator overloading conventions, and the `size` property, along with other useful member functions: ``` class Array<T> private constructor() { val size: Int operator fun get(index: Int): T operator fun set(index: Int, value: T): Unit operator fun iterator(): Iterator<T> // ... } ``` To create an array, use the function `arrayOf()` and pass the item values to it, so that `arrayOf(1, 2, 3)` creates an array `[1, 2, 3]`. Alternatively, the `arrayOfNulls()` function can be used to create an array of a given size filled with `null` elements. Another option is to use the `Array` constructor that takes the array size and the function that returns values of array elements given its index: ``` fun main() { //sampleStart // Creates an Array<String> with values ["0", "1", "4", "9", "16"] val asc = Array(5) { i -> (i * i).toString() } asc.forEach { println(it) } //sampleEnd } ``` The `[]` operation stands for calls to member functions `get()` and `set()`. Arrays in Kotlin are *invariant*. This means that Kotlin does not let us assign an `Array<String>` to an `Array<Any>`, which prevents a possible runtime failure (but you can use `Array<out Any>`, see [Type Projections](generics#type-projections)). Primitive type arrays --------------------- Kotlin also has classes that represent arrays of primitive types without boxing overhead: `ByteArray`, `ShortArray`, `IntArray`, and so on. These classes have no inheritance relation to the `Array` class, but they have the same set of methods and properties. Each of them also has a corresponding factory function: ``` val x: IntArray = intArrayOf(1, 2, 3) x[0] = x[1] + x[2] ``` ``` // Array of int of size 5 with values [0, 0, 0, 0, 0] val arr = IntArray(5) // Example of initializing the values in the array with a constant // Array of int of size 5 with values [42, 42, 42, 42, 42] val arr = IntArray(5) { 42 } // Example of initializing the values in the array using a lambda // Array of int of size 5 with values [0, 1, 2, 3, 4] (values initialized to their index value) var arr = IntArray(5) { it * 1 } ``` Last modified: 10 January 2023 [Strings](strings) [Unsigned integer types](unsigned-integer-types) kotlin Inline classes Inline classes ============== Sometimes it is necessary for business logic to create a wrapper around some type. However, it introduces runtime overhead due to additional heap allocations. Moreover, if the wrapped type is primitive, the performance hit is terrible, because primitive types are usually heavily optimized by the runtime, while their wrappers don't get any special treatment. To solve such issues, Kotlin introduces a special kind of class called an *inline class*. Inline classes are a subset of [value-based classes](https://github.com/Kotlin/KEEP/blob/master/notes/value-classes.md). They don't have an identity and can only hold values. To declare an inline class, use the `value` modifier before the name of the class: ``` value class Password(private val s: String) ``` To declare an inline class for the JVM backend, use the `value` modifier along with the `@JvmInline` annotation before the class declaration: ``` // For JVM backends @JvmInline value class Password(private val s: String) ``` An inline class must have a single property initialized in the primary constructor. At runtime, instances of the inline class will be represented using this single property (see details about runtime representation [below](#representation)): ``` // No actual instantiation of class 'Password' happens // At runtime 'securePassword' contains just 'String' val securePassword = Password("Don't try this in production") ``` This is the main feature of inline classes, which inspired the name *inline*: data of the class is *inlined* into its usages (similar to how content of [inline functions](inline-functions) is inlined to call sites). Members ------- Inline classes support some functionality of regular classes. In particular, they are allowed to declare properties and functions, and have the `init` block: ``` @JvmInline value class Name(val s: String) { init { require(s.length > 0) { } } val length: Int get() = s.length fun greet() { println("Hello, $s") } } fun main() { val name = Name("Kotlin") name.greet() // method `greet` is called as a static method println(name.length) // property getter is called as a static method } ``` Inline class properties cannot have [backing fields](properties#backing-fields). They can only have simple computable properties (no `lateinit`/delegated properties). Inheritance ----------- Inline classes are allowed to inherit from interfaces: ``` interface Printable { fun prettyPrint(): String } @JvmInline value class Name(val s: String) : Printable { override fun prettyPrint(): String = "Let's $s!" } fun main() { val name = Name("Kotlin") println(name.prettyPrint()) // Still called as a static method } ``` It is forbidden for inline classes to participate in a class hierarchy. This means that inline classes cannot extend other classes and are always `final`. Representation -------------- In generated code, the Kotlin compiler keeps a *wrapper* for each inline class. Inline class instances can be represented at runtime either as wrappers or as the underlying type. This is similar to how `Int` can be [represented](numbers#numbers-representation-on-the-jvm) either as a primitive `int` or as the wrapper `Integer`. The Kotlin compiler will prefer using underlying types instead of wrappers to produce the most performant and optimized code. However, sometimes it is necessary to keep wrappers around. As a rule of thumb, inline classes are boxed whenever they are used as another type. ``` interface I @JvmInline value class Foo(val i: Int) : I fun asInline(f: Foo) {} fun <T> asGeneric(x: T) {} fun asInterface(i: I) {} fun asNullable(i: Foo?) {} fun <T> id(x: T): T = x fun main() { val f = Foo(42) asInline(f) // unboxed: used as Foo itself asGeneric(f) // boxed: used as generic type T asInterface(f) // boxed: used as type I asNullable(f) // boxed: used as Foo?, which is different from Foo // below, 'f' first is boxed (while being passed to 'id') and then unboxed (when returned from 'id') // In the end, 'c' contains unboxed representation (just '42'), as 'f' val c = id(f) } ``` Because inline classes may be represented both as the underlying value and as a wrapper, [referential equality](equality#referential-equality) is pointless for them and is therefore prohibited. Inline classes can also have a generic type parameter as the underlying type. In this case, the compiler maps it to `Any?` or, generally, to the upper bound of the type parameter. ``` @JvmInline value class UserId<T>(val value: T) fun compute(s: UserId<String>) {} // compiler generates fun compute-<hashcode>(s: Any?) ``` ### Mangling Since inline classes are compiled to their underlying type, it may lead to various obscure errors, for example unexpected platform signature clashes: ``` @JvmInline value class UInt(val x: Int) // Represented as 'public final void compute(int x)' on the JVM fun compute(x: Int) { } // Also represented as 'public final void compute(int x)' on the JVM! fun compute(x: UInt) { } ``` To mitigate such issues, functions using inline classes are *mangled* by adding some stable hashcode to the function name. Therefore, `fun compute(x: UInt)` will be represented as `public final void compute-<hashcode>(int x)`, which solves the clash problem. ### Calling from Java code You can call functions that accept inline classes from Java code. To do so, you should manually disable mangling: add the `@JvmName` annotation before the function declaration: ``` @JvmInline value class UInt(val x: Int) fun compute(x: Int) { } @JvmName("computeUInt") fun compute(x: UInt) { } ``` Inline classes vs type aliases ------------------------------ At first sight, inline classes seem very similar to [type aliases](type-aliases). Indeed, both seem to introduce a new type and both will be represented as the underlying type at runtime. However, the crucial difference is that type aliases are *assignment-compatible* with their underlying type (and with other type aliases with the same underlying type), while inline classes are not. In other words, inline classes introduce a truly *new* type, contrary to type aliases which only introduce an alternative name (alias) for an existing type: ``` typealias NameTypeAlias = String @JvmInline value class NameInlineClass(val s: String) fun acceptString(s: String) {} fun acceptNameTypeAlias(n: NameTypeAlias) {} fun acceptNameInlineClass(p: NameInlineClass) {} fun main() { val nameAlias: NameTypeAlias = "" val nameInlineClass: NameInlineClass = NameInlineClass("") val string: String = "" acceptString(nameAlias) // OK: pass alias instead of underlying type acceptString(nameInlineClass) // Not OK: can't pass inline class instead of underlying type // And vice versa: acceptNameTypeAlias(string) // OK: pass underlying type instead of alias acceptNameInlineClass(string) // Not OK: can't pass underlying type instead of inline class } ``` Inline classes and delegation ----------------------------- Implementation by delegation to inlined value of inlined class is allowed with interfaces: ``` interface MyInterface { fun bar() fun foo() = "foo" } @JvmInline value class MyInterfaceWrapper(val myInterface: MyInterface) : MyInterface by myInterface fun main() { val my = MyInterfaceWrapper(object : MyInterface { override fun bar() { // body } }) println(my.foo()) // prints "foo" } ``` Last modified: 10 January 2023 [Enum classes](enum-classes) [Object expressions and declarations](object-declarations)
programming_docs
kotlin Maven Maven ===== Plugin and versions ------------------- The *kotlin-maven-plugin* compiles Kotlin sources and modules. Currently, only Maven v3 is supported. Define the version of Kotlin you want to use via a *kotlin.version* property: ``` <properties> <kotlin.version>1.8.0</kotlin.version> </properties> ``` Dependencies ------------ Kotlin has an extensive standard library that can be used in your applications. To use the standard library in your project, add the following dependency in the pom file: ``` <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>${kotlin.version}</version> </dependency> </dependencies> ``` If your project uses [Kotlin reflection](../api/latest/jvm/stdlib/kotlin.reflect.full/index) or testing facilities, you need to add the corresponding dependencies as well. The artifact IDs are `kotlin-reflect` for the reflection library, and `kotlin-test` and `kotlin-test-junit` for the testing libraries. Compile Kotlin-only source code ------------------------------- To compile source code, specify the source directories in the `<build>` tag: ``` <build> <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> </build> ``` The Kotlin Maven Plugin needs to be referenced to compile the sources: ``` <build> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <goals> <goal>test-compile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ``` Compile Kotlin and Java sources ------------------------------- To compile projects that include Kotlin and Java source code, invoke the Kotlin compiler before the Java compiler. In maven terms that means that `kotlin-maven-plugin` should be run before `maven-compiler-plugin` using the following method, making sure that the `kotlin` plugin comes before the `maven-compiler-plugin` in your `pom.xml` file: ``` <build> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions> <execution> <id>compile</id> <goals> <goal>compile</goal> </goals> <configuration> <sourceDirs> <sourceDir>${project.basedir}/src/main/kotlin</sourceDir> <sourceDir>${project.basedir}/src/main/java</sourceDir> </sourceDirs> </configuration> </execution> <execution> <id>test-compile</id> <goals> <goal>test-compile</goal> </goals> <configuration> <sourceDirs> <sourceDir>${project.basedir}/src/test/kotlin</sourceDir> <sourceDir>${project.basedir}/src/test/java</sourceDir> </sourceDirs> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.5.1</version> <executions> <!-- Replacing default-compile as it is treated specially by maven --> <execution> <id>default-compile</id> <phase>none</phase> </execution> <!-- Replacing default-testCompile as it is treated specially by maven --> <execution> <id>default-testCompile</id> <phase>none</phase> </execution> <execution> <id>java-compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>java-test-compile</id> <phase>test-compile</phase> <goals> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> </plugins> </build> ``` Incremental compilation ----------------------- To make your builds faster, you can enable incremental compilation for Maven by defining the `kotlin.compiler.incremental` property: ``` <properties> <kotlin.compiler.incremental>true</kotlin.compiler.incremental> </properties> ``` Alternatively, run your build with the `-Dkotlin.compiler.incremental=true` option. Annotation processing --------------------- See the description of [Kotlin annotation processing tool](kapt) (`kapt`). Jar file -------- To create a small Jar file containing just the code from your module, include the following under `build->plugins` in your Maven pom.xml file, where `main.class` is defined as a property and points to the main Kotlin or Java class: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <mainClass>${main.class}</mainClass> </manifest> </archive> </configuration> </plugin> ``` Self-contained Jar file ----------------------- To create a self-contained Jar file containing the code from your module along with dependencies, include the following under `build->plugins` in your Maven pom.xml file, where `main.class` is defined as a property and points to the main Kotlin or Java class: ``` <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>2.6</version> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <archive> <manifest> <mainClass>${main.class}</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </execution> </executions> </plugin> ``` This self-contained jar file can be passed directly to a JRE to run your application: ``` java -jar target/mymodule-0.0.1-SNAPSHOT-jar-with-dependencies.jar ``` Specifying compiler options --------------------------- Additional options and arguments for the compiler can be specified as tags under the `<configuration>` element of the Maven plugin node: ``` <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>${kotlin.version}</version> <executions>...</executions> <configuration> <nowarn>true</nowarn> <!-- Disable warnings --> <args> <arg>-Xjsr305=strict</arg> <!-- Enable strict mode for JSR-305 annotations --> ... </args> </configuration> </plugin> ``` Many of the options can also be configured through properties: ``` <project ...> <properties> <kotlin.compiler.languageVersion>1.0</kotlin.compiler.languageVersion> </properties> </project> ``` The following attributes are supported: ### Attributes common to JVM and JS | Name | Property name | Description | Possible values | Default value | | --- | --- | --- | --- | --- | | `nowarn` | | Generate no warnings | true, false | false | | `languageVersion` | kotlin.compiler.languageVersion | Provide source compatibility with the specified version of Kotlin | "1.4" (DEPRECATED), "1.5", "1.6", "1.7", "1.8", "1.9" | | `apiVersion` | kotlin.compiler.apiVersion | Allow using declarations only from the specified version of bundled libraries | "1.3" (DEPRECATED), "1.4" (DEPRECATED), "1.5", "1.6", "1.7", "1.8", "1.9" | | `sourceDirs` | | The directories containing the source files to compile | | The project source roots | | `compilerPlugins` | | Enabled compiler plugins | | [] | | `pluginOptions` | | Options for compiler plugins | | [] | | `args` | | Additional compiler arguments | | [] | ### Attributes specific to JVM | Name | Property name | Description | Possible values | Default value | | --- | --- | --- | --- | --- | | `jvmTarget` | `kotlin.compiler.jvmTarget` | Target version of the generated JVM bytecode | "1.8", "9", "10", ..., "19" | "1.8" | | `jdkHome` | `kotlin.compiler.jdkHome` | Include a custom JDK from the specified location into the classpath instead of the default JAVA\_HOME | | | ### Attributes specific to JS | Name | Property name | Description | Possible values | Default value | | --- | --- | --- | --- | --- | | `outputFile` | | Destination \*.js file for the compilation result | | | | `metaInfo` | | Generate .meta.js and .kjsm files with metadata. Use to create a library | true, false | true | | `sourceMap` | | Generate source map | true, false | false | | `sourceMapEmbedSources` | | Embed source files into source map | "never", "always", "inlining" | "inlining" | | `sourceMapPrefix` | | Add the specified prefix to paths in the source map | | | | `moduleKind` | | The kind of JS module generated by the compiler | "umd", "commonjs", "amd", "plain" | "umd" | Using BOM --------- To use a Kotlin [Bill of Materials (BOM)](https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#bill-of-materials-bom-poms), write a dependency on [`kotlin-bom`](https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-bom): ``` <dependencyManagement> <dependencies> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-bom</artifactId> <version>1.8.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ``` Generating documentation ------------------------ The standard Javadoc generation plugin (`maven-javadoc-plugin`) does not support Kotlin code. To generate documentation for Kotlin projects, use [Dokka](https://github.com/Kotlin/dokka); please refer to the [Dokka README](https://github.com/Kotlin/dokka/blob/master/README.md#using-the-maven-plugin) for configuration instructions. Dokka supports mixed-language projects and can generate output in multiple formats, including standard Javadoc. OSGi ---- For OSGi support see the [Kotlin OSGi page](kotlin-osgi). Last modified: 10 January 2023 [Support for Gradle plugin variants](gradle-plugin-variants) [Ant](ant) kotlin Lincheck guide Lincheck guide ============== Lincheck is a practical and user-friendly framework for testing concurrent algorithms on the JVM. It provides a simple and declarative way to write concurrent tests. With the Lincheck framework, instead of describing how to perform tests, you can specify *what to test* by declaring all the operations to examine and the required correctness property. As a result, a typical concurrent Lincheck test contains only about 15 lines. When given a list of operations, Lincheck automatically: * Generates a set of random concurrent scenarios. * Examines them using either stress-testing or bounded model checking. * Verifies that the results of each invocation satisfy the required correctness property (linearizability is the default one). Add Lincheck to your project ---------------------------- To enable the Lincheck support, include the corresponding repository and dependency to the Gradle configuration. In your `build.gradle(.kts)` file, add the following: ``` repositories { mavenCentral() } dependencies { testImplementation("org.jetbrains.kotlinx:lincheck:2.16") } ``` ``` repositories { mavenCentral() } dependencies { testImplementation "org.jetbrains.kotlinx:lincheck:2.16" } ``` Explore Lincheck ---------------- This guide will help you get in touch with the framework and try the most useful features with examples. Learn the Lincheck features step-by-step: 1. [Write your first test with Lincheck](introduction) 2. [Choose your testing strategy](testing-strategies) 3. [Configure operation arguments](operation-arguments) 4. [Use modular testing in model checking](modular-testing) 5. [Consider popular algorithm constraints](constraints) 6. [Check the algorithm for non-blocking progress guarantees](progress-guarantees) 7. [Define sequential specification of the algorithm](sequential-specification) Additional references --------------------- * Workshop. Lincheck: Testing concurrency on the JVM: [Part 1](https://www.youtube.com/watch?v=YNtUK9GK4pA), Hydra 2021, EN * Workshop. Lincheck: Testing concurrency on the JVM: [Part 2](https://www.youtube.com/watch?v=EW7mkAOErWw), Hydra 2021, EN * [Lincheck. Testing concurrent data structures in Java](https://www.youtube.com/watch?v=YAb7YoEd6mM), Heisenbug 2019, RU * [Testing concurrent algorithms with Lincheck](https://www.youtube.com/watch?v=9cB36asOjPo), Joker 2019, RU * [Lincheck: testing concurrent data structures on Java](https://www.youtube.com/watch?v=hwbpUEGHvvY), Hydra 2019, RU * [Lock-free algorithms testing](https://www.youtube.com/watch?v=_0_HOnTSS0E), Joker 2017, RU Last modified: 10 January 2023 [Serialization](serialization) [Write your first test with Lincheck](introduction) kotlin Migrate to Kotlin code style Migrate to Kotlin code style ============================ Kotlin coding conventions and IntelliJ IDEA formatter ----------------------------------------------------- [Kotlin coding conventions](coding-conventions) affect several aspects of writing idiomatic Kotlin, and a set of formatting recommendations aimed at improving Kotlin code readability is among them. Unfortunately, the code formatter built into IntelliJ IDEA had to work long before this document was released and now has a default setup that produces different formatting from what is now recommended. It may seem a logical next step to remove this obscurity by switching the defaults in IntelliJ IDEA and make formatting consistent with the Kotlin coding conventions. But this would mean that all the existing Kotlin projects will have a new code style enabled the moment the Kotlin plugin is installed. Not really the expected result for plugin update, right? That's why we have the following migration plan instead: * Enable the official code style formatting by default starting from Kotlin 1.3 and only for new projects (old formatting can be enabled manually) * Authors of existing projects may choose to migrate to the Kotlin coding conventions * Authors of existing projects may choose to explicitly declare using the old code style in a project (this way the project won't be affected by switching to the defaults in the future) * Switch to the default formatting and make it consistent with Kotlin coding conventions in Kotlin 1.4 Differences between "Kotlin coding conventions" and "IntelliJ IDEA default code style" -------------------------------------------------------------------------------------- The most notable change is in the continuation indentation policy. There's a nice idea to use the double indent for showing that a multi-line expression hasn't ended on the previous line. This is a very simple and general rule, but several Kotlin constructions look a bit awkward when they are formatted this way. In Kotlin coding conventions, it's recommended to use a single indent in cases where the long continuation indent has been forced before. ![Code formatting](https://kotlinlang.org/docs/images/code-formatting-diff.png "Code formatting")In practice, quite a bit of code is affected, so this can be considered a major code style update. Migration to a new code style discussion ---------------------------------------- A new code style adoption might be a very natural process if it starts with a new project, when there's no code formatted in the old way. That is why starting from version 1.3, the Kotlin IntelliJ Plugin creates new projects with formatting from the [Coding conventions](coding-conventions) document which is enabled by default. Changing formatting in an existing project is a far more demanding task, and should probably be started with discussing all the caveats with the team. The main disadvantage of changing the code style in an existing project is that the blame/annotate VCS feature will point to irrelevant commits more often. While each VCS has some kind of way to deal with this problem (["Annotate Previous Revision"](https://www.jetbrains.com/help/idea/investigate-changes.html) can be used in IntelliJ IDEA), it's important to decide if a new style is worth all the effort. The practice of separating reformatting commits from meaningful changes can help a lot with later investigations. Also migrating can be harder for larger teams because committing a lot of files in several subsystems may produce merging conflicts in personal branches. And while each conflict resolution is usually trivial, it's still wise to know if there are large feature branches currently in work. In general, for small projects, we recommend converting all the files at once. For medium and large projects the decision may be tough. If you are not ready to update many files right away you may decide to migrate module by module, or continue with gradual migration for modified files only. Migration to a new code style ----------------------------- Switching to the Kotlin Coding Conventions code style can be done in **Settings/Preferences** | **Editor** | **Code Style** | **Kotlin** dialog. Switch scheme to **Project** and activate **Set from...** | **Kotlin style guide**. In order to share those changes for all project developers `.idea/codeStyle` folder have to be committed to VCS. If an external build system is used for configuring the project, and it's been decided not to share `.idea/codeStyle` folder, Kotlin coding conventions can be forced with an additional property: ### In Gradle Add `kotlin.code.style=official` property to the `gradle.properties` file at the project root and commit the file to VCS. ### In Maven Add `kotlin.code.style official` property to root `pom.xml` project file. `<properties> <kotlin.code.style>official</kotlin.code.style> </properties>` After updating your code style settings, activate **Reformat Code** in the project view on the desired scope. ![Reformat code](https://kotlinlang.org/docs/images/reformat-code.png "Reformat code")For a gradual migration, it's possible to enable the **File is not formatted according to project settings** inspection. It will highlight the places that should be reformatted. After enabling the **Apply only to modified files** option, inspection will show formatting problems only in modified files. Such files are probably going to be committed soon anyway. Store old code style in project ------------------------------- It's always possible to explicitly set the IntelliJ IDEA code style as the correct code style for the project: 1. In **Settings/Preferences** | **Editor** | **Code Style** | **Kotlin**, switch to the **Project** scheme. 2. Open the **Load/Save** tab and in the **Use defaults from** select **Kotlin obsolete IntelliJ IDEA codestyle**. In order to share the changes across the project developers `.idea/codeStyle` folder, it has to be committed to VCS. Alternatively, **kotlin.code.style**=**obsolete** can be used for projects configured with Gradle or Maven. Last modified: 10 January 2023 [IDEs for Kotlin development](kotlin-ide) [Run code snippets](run-code-snippets)
programming_docs
kotlin Write your first test with Lincheck Write your first test with Lincheck =================================== This tutorial demonstrates how to write your first Lincheck test, set up the Lincheck framework, and use its basic API. You will create a new IntelliJ IDEA project with an incorrect concurrent counter implementation and write a test for it, finding and analyzing the bug afterward. Create a project ---------------- 1. Open an existing Kotlin project in IntelliJ IDEA or [create a new one](jvm-get-started). When creating a project, use the Gradle build system. 2. In the `src/main/kotlin` directory, open the `main.kt` file. 3. Replace the code in `main.kt` with the following counter implementation: ``` class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } ``` Your Lincheck test will check whether the counter is thread-safe. Add required dependencies ------------------------- 1. Open the `build.gradle(.kts)` file and make sure that `mavenCentral()` is added to the repository list. 2. Add the following dependencies to the Gradle configuration: ``` repositories { mavenCentral() } dependencies { // Lincheck dependency testImplementation("org.jetbrains.kotlinx:lincheck:2.16") // This dependency allows you to work with kotlin.test and JUnit: testImplementation("junit:junit:4.13") } ``` ``` repositories { mavenCentral() } dependencies { // Lincheck dependency testImplementation "org.jetbrains.kotlinx:lincheck:2.16" // This dependency allows you to work with kotlin.test and JUnit: testImplementation "junit:junit:4.13" } ``` Write and run the test ---------------------- 1. In the `src/test/kotlin` directory, create a `BasicCounterTest.kt` file and add the following code: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.* import org.jetbrains.kotlinx.lincheck.strategy.stress.* import org.junit.* class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class BasicCounterTest { private val c = Counter() // Initial state // Operations on the Counter @Operation fun inc() = c.inc() @Operation fun get() = c.get() @Test // JUnit fun stressTest() = StressOptions().check(this::class) // The magic button } ``` This Lincheck test automatically: * Generates several random concurrent scenarios with the specified `inc()` and `dec()` operations. * Performs a lot of invocations for each of the generated scenarios. * Verifies that each invocation result is correct. 2. Run the test above, and you will see the following error: ``` = Invalid execution results = Parallel part: | inc(): 1 | inc(): 1 | ``` Here, Lincheck found an execution that violates the counter atomicity – two concurrent increments ended with the same result `1`. It means that one increment has been lost, and the behavior of the counter is incorrect. Trace the invalid execution --------------------------- Besides showing invalid execution results, Lincheck can also provide an interleaving that leads to the error. This feature is accessible with the [model checking](testing-strategies#model-checking) testing strategy, which examines numerous executions with a bounded number of context switches. 1. To switch the testing strategy, replace the `options` type from `StressOptions()` to `ModelCheckingOptions()`. The updated `BasicCounterTest` class will look like this: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* import org.jetbrains.kotlinx.lincheck.verifier.* import org.junit.* class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class BasicCounterTest { private val c = Counter() @Operation fun getAndInc() = c.getAndInc() @Operation fun get() = c.get() @Test fun modelCheckingTest() = ModelCheckingOptions().check(this::class) } ``` 2. Run the test again. You will get the execution trace that leads to incorrect results: ``` = Invalid execution results = Parallel part: | inc(): 1 | inc(): 1 | = The following interleaving leads to the error = Parallel part trace: | | inc() | | | inc(): 1 at BasicCounterTest.inc(BasicCounterTest.kt:11) | | | value.READ: 0 at Counter.inc(Counter.kt:5) | | | switch | | inc(): 1 | | | thread is finished | | | | value.WRITE(1) at Counter.inc(Counter.kt:5) | | | value.READ: 1 at Counter.inc(Counter.kt:5) | | | result: 1 | | | thread is finished | ``` According to the trace, the following events have occurred: * **T2**: The second thread starts the `inc()` operation, reading the current counter value (`value.READ: 0`) and pausing. * **T1**: The first thread executes `inc()`, which returns `1`, and finishes. * **T2**: The second thread resumes and increments the previously obtained counter value, incorrectly updating the counter to `1`. Test the Java standard library ------------------------------ Let's now find a bug in the standard Java's `ConcurrentLinkedDeque` class. The Lincheck test below finds a race between removing and adding an element to the head of the deque: ``` import org.jetbrains.kotlinx.lincheck.* import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* import org.junit.* import java.util.concurrent.* class ConcurrentDequeTest { private val deque = ConcurrentLinkedDeque<Int>() @Operation fun addFirst(e: Int) = deque.addFirst(e) @Operation fun addLast(e: Int) = deque.addLast(e) @Operation fun pollFirst() = deque.pollFirst() @Operation fun pollLast() = deque.pollLast() @Operation fun peekFirst() = deque.peekFirst() @Operation fun peekLast() = deque.peekLast() @Test fun modelCheckingTest() = ModelCheckingOptions().check(this::class) } ``` Run `modelCheckingTest()`. The test will fail with the following output: ``` = Invalid execution results = Init part: [addLast(4): void] Parallel part: | pollFirst(): 4 | addFirst(-4): void | | | peekLast(): 4 [-,1] | --- values in "[..]" brackets indicate the number of completed operations in each of the parallel threads seen at the beginning of the current operation --- = The following interleaving leads to the error = Parallel part trace: | pollFirst() | | | pollFirst(): 4 at ConcurrentDequeTest.pollFirst(ConcurrentDequeTest.kt:39) | | | first(): Node@1 at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:915) | | | item.READ: null at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:917) | | | next.READ: Node@2 at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:925) | | | item.READ: 4 at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:917) | | | prev.READ: null at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:919) | | | switch | | | | addFirst(-4): void | | | peekLast(): 4 | | | thread is finished | | compareAndSet(Node@2,4,null): true at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:920) | | | unlink(Node@2) at ConcurrentLinkedDeque.pollFirst(ConcurrentLinkedDeque.java:921) | | | result: 4 | | | thread is finished | | ``` Next step --------- Choose [your testing strategy and configure test execution](testing-strategies). See also -------- * [How to generate operation arguments](operation-arguments) * [Popular algorithm constraints](constraints) * [Modular testing in model checking](modular-testing) * [Checking for non-blocking progress guarantees](progress-guarantees) * [Define sequential specification of the algorithm](sequential-specification) Last modified: 10 January 2023 [Lincheck guide](lincheck-guide) [Stress testing and model checking](testing-strategies) kotlin Modular testing Modular testing =============== When constructing new algorithms, it's common to use existing data structures as building blocks. As these data structures are typically non-trivial, the number of possible interleavings increases significantly. If you consider such underlying data structures to be correct and treat their operations as atomic, you can check only meaningful interleavings, thus increasing the testing quality. Lincheck makes it possible with the *modular testing* feature available for the [model checking strategy](testing-strategies#model-checking). Consider the `MultiMap` implementation below, which is based on top of the modern `j.u.c.ConcurrentHashMap`: ``` import java.util.concurrent.* class MultiMap<K, V> { val map = ConcurrentHashMap<K, List<V>>() // Adds the value to the list by the given key // Contains the race :( fun add(key: K, value: V) { val list = map[key] if (list == null) { map[key] = listOf(value) } else { map[key] = list + value } } fun get(key: K): List<V> = map[key] ?: emptyList() } ``` It is already guaranteed that `j.u.c.ConcurrentHashMap` is linearizable, so its operations can be considered atomic. You can specify this guarantee with the `addGuarantee` option in the `ModelCheckingOptions()` in your test: ``` import java.util.concurrent.* import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.paramgen.* import org.jetbrains.kotlinx.lincheck.strategy.managed.* import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* import org.junit.* class MultiMap<K,V> { val map = ConcurrentHashMap<K, List<V>>() // Adds the value to the list by the given key // Contains the race :( fun add(key: K, value: V) { val list = map[key] if (list == null) { map[key] = listOf(value) } else { map[key] = list + value } } fun get(key: K): List<V> = map[key] ?: emptyList() } @Param(name = "key", gen = IntGen::class, conf = "1:2") class MultiMapTest { private val map = MultiMap<Int, Int>() @Operation fun add(@Param(name = "key") key: Int, value: Int) = map.add(key, value) @Operation fun get(@Param(name = "key") key: Int) = map.get(key) @Test fun modularTest() = ModelCheckingOptions() .addGuarantee(forClasses(ConcurrentHashMap::class).allMethods().treatAsAtomic()) // Note that with the atomicity guarantees set, Lincheck can examine all possible interleavings, // so the test successfully passes when the number of invocations is set to `Int.MAX_VALUE` // If you comment the line above, the test takes a lot of time and likely fails with `OutOfMemoryError`. .invocationsPerIteration(Int.MAX_VALUE) .check(this::class) } ``` Next step --------- Learn how to test data structures that set [access constraints on the execution](constraints), such as single-producer single-consumer queues. Last modified: 10 January 2023 [Operation arguments](operation-arguments) [Data structure constraints](constraints) kotlin Concurrency overview Concurrency overview ==================== When you extend your development experience from Android to Kotlin Multiplatform Mobile, you will encounter a different state and concurrency model for iOS. This is a Kotlin/Native model that compiles Kotlin code to native binaries that can run without a virtual machine, for example on iOS. Having mutable memory available to multiple threads at the same time, if unrestricted, is known to be risky and prone to error. Languages like Java, C++, and Swift/Objective-C let multiple threads access the same state in an unrestricted way. Concurrency issues are unlike other programming issues in that they are often very difficult to reproduce. You may not see them locally while developing, and they may happen sporadically. And sometimes you can only see them in production under load. In short, just because your tests pass, you can't necessarily be sure that your code is OK. Not all languages are designed this way. JavaScript simply does not allow you to access the same state concurrently. At the other end of the spectrum is Rust, with its language-level management of concurrency and states, which makes it very popular. Rules for state sharing ----------------------- Kotlin/Native introduces rules for sharing states between threads. These rules exist to prevent unsafe shared access to mutable states. If you come from a JVM background and write concurrent code, you may need to change the way you architect your data, but doing so will allow you to achieve the same results without risky side effects. It is also important to point out that there are [ways to work around these rules](multiplatform-mobile-concurrent-mutability). The intent is to make working around these rules something that you rarely have to do, if ever. There are just two simple rules regarding state and concurrency. ### Rule 1: Mutable state == 1 thread If your state is mutable, only one thread can *see* it at a time. Any regular class state that you would normally use in Kotlin is considered by the Kotlin/Native runtime as *mutable*. If you aren't using concurrency, Kotlin/Native behaves the same as any other Kotlin code, with the exception of [global state](#global-state). ``` data class SomeData(var count:Int) fun simpleState(){ val sd = SomeData(42) sd.count++ println("My count is ${sd.count}") // It will be 43 } ``` If there's only one thread, you won't have concurrency issues. Technically this is referred to as *thread confinement*, which means that you cannot change the UI from a background thread. Kotlin/Native's state rules formalize that concept for all threads. ### Rule 2: Immutable state == many threads If a state can't be changed, multiple threads can safely access it. In Kotlin/Native, *immutable* doesn't mean everything is a `val`. It means *frozen state*. Immutable and frozen state -------------------------- The example below is immutable by definition – it has 2 `val` elements, and both are of final immutable types. ``` data class SomeData(val s:String, val i:Int) ``` This next example may be immutable or mutable. It is not clear what `SomeInterface` will do internally at compile time. In Kotlin, it is not possible to determine deep immutability statically at compile time. ``` data class SomeData(val s:String, val i:SomeInterface) ``` Kotlin/Native needs to verify that some part of a state really is immutable at runtime. The runtime could simply go through the whole state and verify that each part is deeply immutable, but that would be inflexible. And if you needed to do that every time the runtime wanted to check mutability, there would be significant consequences for performance. Kotlin/Native defines a new runtime state called *frozen*. Any instance of an object may be frozen. If an object is frozen: 1. You cannot change any part of its state. Attempting to do so will result in a runtime exception: `InvalidMutabilityException`. A frozen object instance is 100%, runtime-verified, immutable. 2. Everything it references is also frozen. All other objects it has a reference to are guaranteed to be frozen. This means that, when the runtime needs to determine whether an object can be shared with another thread, it only needs to check whether that object is frozen. If it is, the whole graph is also frozen and is safe to be shared. The Native runtime adds an extension function `freeze()` to all classes. Calling `freeze()` will freeze an object, and everything referenced by the object, recursively. ``` data class MoreData(val strData: String, var width: Float) data class SomeData(val moreData: MoreData, var count: Int) //... val sd = SomeData(MoreData("abc", 10.0), 0) sd.freeze() ``` ![Freezing state](https://kotlinlang.org/docs/images/freezing-state.png)* `freeze()` is a one-way operation. You can't *unfreeze* something. * `freeze()` is not available in shared Kotlin code, but several libraries provide expect and actual declarations for using it in shared code. However, if you're using a concurrency library, like [`kotlinx.coroutines`](https://github.com/Kotlin/kotlinx.coroutines), it will likely freeze data that crosses thread boundaries automatically. `freeze` is not unique to Kotlin. You can also find it in [Ruby](https://www.honeybadger.io/blog/when-to-use-freeze-and-frozen-in-ruby/) and [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze). Global state ------------ Kotlin allows you to define a state as globally available. If left simply mutable, the global state would violate [Rule 1](#rule-1-mutable-state-1-thread). To conform to Kotlin/Native's state rules, the global state has some special conditions. These conditions freeze the state or make it visible only to a single thread. ### Global object Global `object` instances are frozen by default. This means that all threads can access them, but they are immutable. The following won't work. ``` object SomeState{ var count = 0 fun add(){ count++ //This will throw an exception } } ``` Trying to change `count` will throw an exception because `SomeState` is frozen (which means all of its data is frozen). You can make a global object thread *local*, which will allow it to be mutable and give each thread a copy of its state. Annotate it with `@ThreadLocal`. ``` @ThreadLocal object SomeState{ var count = 0 fun add(){ count++ //👍 } } ``` If different threads read `count`, they'll get different values, because each thread has its own copy. These global object rules also apply to companion objects. ``` class SomeState{ companion object{ var count = 0 fun add(){ count++ //This will throw an exception } } } ``` ### Global properties Global properties are a special case. *They are only available to the main thread*, but they are mutable. Accessing them from other threads will throw an exception. ``` val hello = "Hello" //Only main thread can see this ``` You can annotate them with : * `@SharedImmutable`, which will make them globally available but frozen. * `@ThreadLocal`, which will give each thread its own mutable copy. This rule applies to global properties with backing fields. Computed properties and global functions do not have the main thread restriction. Current and future models ------------------------- Kotlin/Native's concurrency rules will require some adjustment in architecture design, but with the help of libraries and new best practices, day to day development is basically unaffected. In fact, adhering to Kotlin/Native's rules regarding multiplatform code will result in safer concurrency across the cross-platform mobile application. In the Kotlin Multiplatform application, you have Android and iOS targets with different state rules. Some teams, generally ones working on larger applications, share code for very specific functionality, and often manage concurrency in the host platform. This will require explicit freezing of states returned from Kotlin, but otherwise, it is straightforward. A more extensive model, where concurrency is managed in Kotlin and the host communicates on its main thread to shared code, is simpler from a state management perspective. Concurrency libraries, like [`kotlinx.coroutines`](https://github.com/Kotlin/kotlinx.coroutines), will help automate freezing. You'll also be able to leverage the power of [coroutines](coroutines-overview) in your code and increase efficiency by sharing more code. However, the current Kotlin/Native concurrency model has a number of deficiencies. For example, mobile developers are used to freely sharing their objects between threads, and they have already developed a number of approaches and architectural patterns to avoid data races while doing so. It is possible to write efficient applications that do not block the main thread using Kotlin/Native, but the ability to do so comes with a steep learning curve. That's why we are working on creating a new memory manager and concurrency model for Kotlin/Native that will help us remove these drawbacks. Learn more about [where we are going with this](https://blog.jetbrains.com/kotlin/2020/07/kotlin-native-memory-management-roadmap/). *This material was prepared by [Touchlab](https://touchlab.co/) for publication by JetBrains.* Last modified: 10 January 2023 [Immutability and concurrency in Kotlin/Native](native-immutability) [Concurrent mutability](multiplatform-mobile-concurrent-mutability)
programming_docs
kotlin FAQ FAQ === What is Kotlin? --------------- Kotlin is an open-source statically typed programming language that targets the JVM, Android, JavaScript and Native. It's developed by [JetBrains](https://www.jetbrains.com). The project started in 2010 and was open source from very early on. The first official 1.0 release was in February 2016. What is the current version of Kotlin? -------------------------------------- The currently released version is 1.8.0, published on December 28, 2022. Is Kotlin free? --------------- Yes. Kotlin is free, has been free and will remain free. It is developed under the Apache 2.0 license and the source code is available [on GitHub](https://github.com/jetbrains/kotlin). Is Kotlin an object-oriented language or a functional one? ---------------------------------------------------------- Kotlin has both object-oriented and functional constructs. You can use it in both OO and FP styles, or mix elements of the two. With first-class support for features such as higher-order functions, function types and lambdas, Kotlin is a great choice if you're doing or exploring functional programming. What advantages does Kotlin give me over the Java programming language? ----------------------------------------------------------------------- Kotlin is more concise. Rough estimates indicate approximately a 40% cut in the number of lines of code. It's also more type-safe, for example, support for non-nullable types makes applications less prone to NPE's. Other features including smart casting, higher-order functions, extension functions and lambdas with receivers provide the ability to write expressive code as well as facilitating creation of DSL. Is Kotlin compatible with the Java programming language? -------------------------------------------------------- Yes. Kotlin is 100% interoperable with the Java programming language and major emphasis has been placed on making sure that your existing codebase can interact properly with Kotlin. You can easily [call Kotlin code from Java](java-to-kotlin-interop) and [Java code from Kotlin](java-interop). This makes adoption much easier and lower-risk. There's also an automated [Java-to-Kotlin converter built into the IDE](mixing-java-kotlin-intellij#converting-an-existing-java-file-to-kotlin-with-j2k) that simplifies migration of existing code. What can I use Kotlin for? -------------------------- Kotlin can be used for any kind of development, be it server-side, client-side web and Android. With Kotlin/Native currently in the works, support for other platforms such as embedded systems, macOS and iOS is coming. People are using Kotlin for mobile and server-side applications, client-side with JavaScript or JavaFX, and data science, just to name a few possibilities. Can I use Kotlin for Android development? ----------------------------------------- Yes. Kotlin is supported as a first-class language on Android. There are hundreds of applications already using Kotlin for Android, such as Basecamp, Pinterest and more. For more information, check out [the resource on Android development](android-overview). Can I use Kotlin for server-side development? --------------------------------------------- Yes. Kotlin is 100% compatible with the JVM and as such you can use any existing frameworks such as Spring Boot, vert.x or JSF. In addition, there are specific frameworks written in Kotlin such as [Ktor](https://github.com/kotlin/ktor). For more information, check out [the resource on server-side development](server-overview). Can I use Kotlin for web development? ------------------------------------- Yes. In addition to using for backend web, you can also use Kotlin/JS for client-side web. Kotlin can use definitions from [DefinitelyTyped](https://definitelytyped.org) to get static typing for common JavaScript libraries, and it is compatible with existing module systems such as AMD and CommonJS. For more information, check out [the resource on client-side development](js-overview). Can I use Kotlin for desktop development? ----------------------------------------- Yes. You can use any Java UI framework such as JavaFx, Swing or other. In addition there are Kotlin specific frameworks such as [TornadoFX](https://github.com/edvin/tornadofx). Can I use Kotlin for native development? ---------------------------------------- Yes. Kotlin/Native is available as a part of Kotlin project. It compiles Kotlin to native code that can run without a VM. It is still in beta, but you can already try it on popular desktop and mobile platforms and even some IoT devices. For more information, check out the [Kotlin/Native documentation](native-overview). What IDEs support Kotlin? ------------------------- Kotlin has full out-of-the-box support in [IntelliJ IDEA](https://www.jetbrains.com/idea/download/) and [Android Studio](https://developer.android.com/kotlin/get-started) with an official Kotlin plugin developed by JetBrains. Other IDEs and source editors, such as Eclipse, Visual Studio Code, and Atom, have Kotlin community-supported plugins. You can also try [Kotlin Playground](https://play.kotlinlang.org) for writing, running, and sharing Kotlin code in your browser. In addition, a [command line compiler](command-line) is available, which provides straightforward support for compiling and running applications. What build tools support Kotlin? -------------------------------- On the JVM side, the main build tools include [Gradle](gradle), [Maven](maven), [Ant](maven), and [Kobalt](https://beust.com/kobalt/home/index.html). There are also some build tools available that target client-side JavaScript. What does Kotlin compile down to? --------------------------------- When targeting the JVM, Kotlin produces Java compatible bytecode. When targeting JavaScript, Kotlin transpiles to ES5.1 and generates code which is compatible with module systems including AMD and CommonJS. When targeting native, Kotlin will produce platform-specific code (via LLVM). Which versions of JVM does Kotlin target? ----------------------------------------- Kotlin lets you choose the version of JVM for execution. By default, the Kotlin/JVM compiler produces Java 8 compatible bytecode. If you want to make use of optimizations available in newer versions of Java, you can explicitly specify the target Java version from 9 to 19. Note that in this case the resulting bytecode might not run on lower versions. Starting with [Kotlin 1.5](whatsnew15#new-default-jvm-target-1-8), the compiler does not support producing bytecode compatible with Java versions below 8. Is Kotlin hard? --------------- Kotlin is inspired by existing languages such as Java, C#, JavaScript, Scala and Groovy. We've tried to ensure that Kotlin is easy to learn, so that people can easily jump on board, reading and writing Kotlin in a matter of days. Learning idiomatic Kotlin and using some more of its advanced features can take a little longer, but overall it is not a complicated language. For more information, check out [our learning materials](learning-materials-overview). What companies are using Kotlin? -------------------------------- There are too many companies using Kotlin to list, but some more visible companies that have publicly declared usage of Kotlin, be this via blog posts, GitHub repositories or talks include [Square](https://medium.com/square-corner-blog/square-open-source-loves-kotlin-c57c21710a17), [Pinterest](https://www.youtube.com/watch?v=mDpnc45WwlI), [Basecamp](https://m.signalvnoise.com/how-we-made-basecamp-3s-android-app-100-kotlin-35e4e1c0ef12), and [Corda](https://docs.corda.net/releases/release-M9.2/further-notes-on-kotlin.html). Who develops Kotlin? -------------------- Kotlin is primarily developed by a team of engineers at JetBrains (current team size is 100+). The lead language designer is [Roman Elizarov](https://twitter.com/relizarov). In addition to the core team, there are also over 250 external contributors on GitHub. Where can I learn more about Kotlin? ------------------------------------ The best place to start is [our website](https://kotlinlang.org). From there you can [download the compiler](command-line), [try it online](https://play.kotlinlang.org) as well as get access to resources. Are there any books on Kotlin? ------------------------------ There are a number of books available for Kotlin. Some of them we have reviewed and can recommend to start with. They are listed on the [Books](books) page. For more books, see the community-maintained list at [kotlin.link](https://kotlin.link/). Are any online courses available for Kotlin? -------------------------------------------- You can learn all the Kotlin essentials while creating working applications with the [Kotlin Basics track](https://hyperskill.org/join/fromdocstoJetSalesStat?redirect=true&next=/tracks/18) on JetBrains Academy. A few other courses you can take: * [Pluralsight Course: Getting Started with Kotlin](https://www.pluralsight.com/courses/kotlin-getting-started) by Kevin Jones * [O'Reilly Course: Introduction to Kotlin Programming](https://www.oreilly.com/library/view/introduction-to-kotlin/9781491964125/) by Hadi Hariri * [Udemy Course: 10 Kotlin Tutorials for Beginneres](https://petersommerhoff.com/dev/kotlin/kotlin-beginner-tutorial/) by Peter Sommerhoff You can also check out the other tutorials and content on our [YouTube channel](https://www.youtube.com/c/Kotlin). Does Kotlin have a community? ----------------------------- Yes. Kotlin has a very vibrant community. Kotlin developers hang out on the [Kotlin forums](https://discuss.kotlinlang.org), [StackOverflow](https://stackoverflow.com/questions/tagged/kotlin) and more actively on the [Kotlin Slack](https://slack.kotlinlang.org) (with close to 30000 members as of April 2020). Are there Kotlin events? ------------------------ Yes. There are many User Groups and Meetups now focused exclusively around Kotlin. You can find [a list on the web site](https://kotlinlang.org/user-groups/user-group-list.html). In addition, there are community-organized [Kotlin Nights](https://kotlinlang.org/community/events.html) events around the world. Is there a Kotlin conference? ----------------------------- Yes. The official annual [KotlinConf](https://kotlinconf.com/) is hosted by JetBrains. It took place in San-Francisco in [2017](https://kotlinconf.com/2017/), Amsterdam in [2018](https://kotlinconf.com/2018/), and Copenhagen in [2019](https://kotlinconf.com/2019/). Kotlin is also being covered in different conferences worldwide. You can find a list of [upcoming talks on the web site](https://kotlinlang.org/community/talks.html?time=upcoming). Is Kotlin on social media? -------------------------- Yes. The most active Kotlin account is [on Twitter](https://twitter.com/kotlin). Any other online Kotlin resources? ---------------------------------- The web site has a bunch of [online resources](https://kotlinlang.org/community/), including [Kotlin Digests](https://kotlin.link) by community members, a [newsletter](http://kotlinweekly.net), a [podcast](https://talkingkotlin.com) and more. Where can I get an HD Kotlin logo? ---------------------------------- Logos can be downloaded [here](https://resources.jetbrains.com/storage/products/kotlin/docs/kotlin_logos.zip). When using the logos, please follow simple rules in the `guidelines.pdf` inside the archive and [Kotlin brand usage guidelines](https://kotlinfoundation.org/guidelines/). Last modified: 10 January 2023 [Teaching Kotlin with EduTools plugin](edu-tools-educator) [Kotlin Evolution](kotlin-evolution) kotlin Document Kotlin code: KDoc and Dokka Document Kotlin code: KDoc and Dokka ==================================== The language used to document Kotlin code (the equivalent of Java's Javadoc) is called **KDoc**. In its essence, KDoc combines Javadoc's syntax for block tags (extended to support Kotlin's specific constructs) and Markdown for inline markup. Generate the documentation -------------------------- Kotlin's documentation generation tool is called [Dokka](https://github.com/Kotlin/dokka). See the [Dokka README](https://github.com/Kotlin/dokka/blob/master/README.md) for usage instructions. Dokka has plugins for Gradle, Maven, and Ant, so you can integrate documentation generation into your build process. KDoc syntax ----------- Just like with Javadoc, KDoc comments start with `/**` and end with `*/`. Every line of the comment may begin with an asterisk, which is not considered part of the contents of the comment. By convention, the first paragraph of the documentation text (the block of text until the first blank line) is the summary description of the element, and the following text is the detailed description. Every block tag begins on a new line and starts with the `@` character. Here's an example of a class documented using KDoc: ``` /** * A group of *members*. * * This class has no useful logic; it's just a documentation example. * * @param T the type of a member in this group. * @property name the name of this group. * @constructor Creates an empty group. */ class Group<T>(val name: String) { /** * Adds a [member] to this group. * @return the new size of the group. */ fun add(member: T): Int { ... } } ``` ### Block tags KDoc currently supports the following block tags: ### @param name Documents a value parameter of a function or a type parameter of a class, property or function. To better separate the parameter name from the description, if you prefer, you can enclose the name of the parameter in brackets. The following two syntaxes are therefore equivalent: `@param name description. @param[name] description.` ### @return Documents the return value of a function. ### @constructor Documents the primary constructor of a class. ### @receiver Documents the receiver of an extension function. ### @property name Documents the property of a class which has the specified name. This tag can be used for documenting properties declared in the primary constructor, where putting a doc comment directly before the property definition would be awkward. ### @throws class, @exception class Documents an exception which can be thrown by a method. Since Kotlin does not have checked exceptions, there is also no expectation that all possible exceptions are documented, but you can still use this tag when it provides useful information for users of the class. ### @sample identifier Embeds the body of the function with the specified qualified name into the documentation for the current element, in order to show an example of how the element could be used. ### @see identifier Adds a link to the specified class or method to the **See also** block of the documentation. ### @author Specifies the author of the element being documented. ### @since Specifies the version of the software in which the element being documented was introduced. ### @suppress Excludes the element from the generated documentation. Can be used for elements which are not part of the official API of a module but still have to be visible externally. Inline markup ------------- For inline markup, KDoc uses the regular [Markdown](https://daringfireball.net/projects/markdown/syntax) syntax, extended to support a shorthand syntax for linking to other elements in the code. ### Links to elements To link to another element (class, method, property, or parameter), simply put its name in square brackets: `Use the method [foo] for this purpose.` If you want to specify a custom label for the link, use the Markdown reference-style syntax: `Use [this method][foo] for this purpose.` You can also use qualified names in the links. Note that, unlike Javadoc, qualified names always use the dot character to separate the components, even before a method name: `Use [kotlin.reflect.KClass.properties] to enumerate the properties of the class.` Names in links are resolved using the same rules as if the name was used inside the element being documented. In particular, this means that if you have imported a name into the current file, you don't need to fully qualify it when you use it in a KDoc comment. Note that KDoc does not have any syntax for resolving overloaded members in links. Since the Kotlin documentation generation tool puts the documentation for all overloads of a function on the same page, identifying a specific overloaded function is not required for the link to work. Module and package documentation -------------------------------- Documentation for a module as a whole, as well as packages in that module, is provided as a separate Markdown file, and the paths to that file is passed to Dokka using the `-include` command line parameter or the corresponding parameters in Ant, Maven and Gradle plugins. Inside the file, the documentation for the module as a whole and for individual packages is introduced by the corresponding first-level headings. The text of the heading must be **Module `<module name>`** for the module, and **Package `<package qualified name>`** for a package. Here's an example content of the file: ``` # Module kotlin-demo The module shows the Dokka syntax usage. # Package org.jetbrains.kotlin.demo Contains assorted useful stuff. ## Level 2 heading Text after this heading is also part of documentation for `org.jetbrains.kotlin.demo` # Package org.jetbrains.kotlin.demo2 Useful stuff in another package. ``` Last modified: 10 January 2023 [Kotlin and continuous integration with TeamCity](kotlin-and-ci) [Kotlin and OSGi](kotlin-osgi) kotlin Kotlin Night guidelines Kotlin Night guidelines ======================= Kotlin Night is a meetup that includes 3-4 talks on Kotlin or related technologies. Event guidelines ---------------- * Please use the [branding materials](kotlin-brand-assets#kotlin-night-brand-assets) we've provided. Having all events and materials in the same style will help keep the Kotlin Night experience consistent. * Kotlin Night should be a free event. A minimal fee can be charged to cover expenses, but it should remain a non-profit event. * The event should be announced publicly and open for all people to attend without any kind of discrimination. * If you publish the contents of the talks online after the event, they must be free and accessible to everyone, without any sign-up or registration procedures. * Recordings are optional but recommended, and they should also be made available. If you decide to record the talks, we suggest having a plan to ensure the quality is good. * The talks should primarily be about Kotlin and should not focus on marketing or sales. * The event can serve food and drinks optionally. Event requirements ------------------ JetBrains is excited to support your Kotlin Night event. Because we want all events to provide the same high-quality experience, we need organizers to ensure that some basic requirements are met for the event to receive JetBrains support. As an organizer, you are responsible for the following aspects of the event: 1. The location and everything required to host the event, including booking a comfortable venue. Please make sure that: * All the participants are aware of the exact date, place, and starting time of the event, along with the event schedule and program. * There is enough space as well as food and beverages, if you provide them, for everyone. * You have a plan with your speakers. This includes a schedule, topics, abstracts for the talks, and any necessary equipment for the presentations. 2. Content and speakers * Feel free to invite presenters from your local community, from neighboring countries, or even from all over the globe. You don't have to have any JetBrains representatives or speakers at your event. However, we are always happy to hear about more Kotlin Nights, so feel free to notify us. 3. Announcements and promotion * Announce your event at least three weeks before the date of a meetup. * Include the schedule, topics, abstracts, and speaker bios in the announcement. * Spread the word on social media. 4. Providing event material to JetBrains after the event * We would be glad to announce your event at [kotlinlang.org](https://kotlinlang.org/community/talks.html), and we would appreciate it if you provided slides and video materials for a follow-up posting. JetBrains support ----------------- JetBrains provides support with: * Access to Kotlin Night Branding, which includes the name and logos * Merchandise, such as stickers and t-shirts for speakers and small souvenirs for attendees * A listing for the event on the Kotlin Talks page * Help to reach out to speakers to take part in the event, if necessary * Help to find a location if possible (via contacts, etc.), as well as help to identify possible partnerships with local businesses Last modified: 10 January 2023 [KUG guidelines](kug-guidelines) [Kotlin brand assets](kotlin-brand-assets)
programming_docs
kotlin Unsigned integer types Unsigned integer types ====================== In addition to [integer types](numbers#integer-types), Kotlin provides the following types for unsigned integer numbers: * `UByte`: an unsigned 8-bit integer, ranges from 0 to 255 * `UShort`: an unsigned 16-bit integer, ranges from 0 to 65535 * `UInt`: an unsigned 32-bit integer, ranges from 0 to 2^32 - 1 * `ULong`: an unsigned 64-bit integer, ranges from 0 to 2^64 - 1 Unsigned types support most of the operations of their signed counterparts. Unsigned arrays and ranges -------------------------- Same as for primitives, each of unsigned type has corresponding type that represents arrays of that type: * `UByteArray`: an array of unsigned bytes * `UShortArray`: an array of unsigned shorts * `UIntArray`: an array of unsigned ints * `ULongArray`: an array of unsigned longs Same as for signed integer arrays, they provide similar API to `Array` class without boxing overhead. When you use unsigned arrays, you'll get a warning that indicates that this feature is not stable yet. To remove the warning, opt-in the `@ExperimentalUnsignedTypes` annotation. It's up to you to decide if your clients have to explicitly opt-in into usage of your API, but keep in mind that unsigned arrays are not a stable feature, so API which uses them can be broken by changes in the language. [Learn more about opt-in requirements](opt-in-requirements). [Ranges and progressions](ranges) are supported for `UInt` and `ULong` by classes `UIntRange`,`UIntProgression`, `ULongRange`, and `ULongProgression`. Together with the unsigned integer types, these classes are stable. Unsigned integers literals -------------------------- To make unsigned integers easier to use, Kotlin provides an ability to tag an integer literal with a suffix indicating a specific unsigned type (similarly to `Float` or `Long`): * `u` and `U` tag is for unsigned literals. The exact type is determined based on the expected type. If no expected type is provided, compiler will use `UInt` or `ULong` depending on the size of literal: ``` val b: UByte = 1u // UByte, expected type provided val s: UShort = 1u // UShort, expected type provided val l: ULong = 1u // ULong, expected type provided val a1 = 42u // UInt: no expected type provided, constant fits in UInt val a2 = 0xFFFF_FFFF_FFFFu // ULong: no expected type provided, constant doesn't fit in UInt ``` * `uL` and `UL` explicitly tag literal as unsigned long: ``` val a = 1UL // ULong, even though no expected type provided and constant fits into UInt ``` Use cases --------- The main use case of unsigned numbers is utilizing the full bit range of an integer to represent positive values. For example, to represent hexadecimal constants that do not fit in signed types such as color in 32-bit `AARRGGBB` format: ``` data class Color(val representation: UInt) val yellow = Color(0xFFCC00CCu) ``` You can use unsigned numbers to initialize byte arrays without explicit `toByte()` literal casts: ``` val byteOrderMarkUtf8 = ubyteArrayOf(0xEFu, 0xBBu, 0xBFu) ``` Another use case is interoperability with native APIs. Kotlin allows representing native declarations that contain unsigned types in the signature. The mapping won't substitute unsigned integers with signed ones keeping the semantics unaltered. ### Non-goals While unsigned integers can only represent positive numbers and zero, it's not a goal to use them where application domain requires non-negative integers. For example, as a type of collection size or collection index value. There are a couple of reasons: * Using signed integers can help to detect accidental overflows and signal error conditions, such as [`List.lastIndex`](../api/latest/jvm/stdlib/kotlin.collections/last-index) being -1 for an empty list. * Unsigned integers cannot be treated as a range-limited version of signed ones because their range of values is not a subset of the signed integers range. Neither signed, nor unsigned integers are subtypes of each other. Last modified: 10 January 2023 [Arrays](arrays) [Type checks and casts](typecasts) kotlin Debug Kotlin/JS code Debug Kotlin/JS code ==================== JavaScript [source maps](https://www.html5rocks.com/en/tutorials/developertools/sourcemaps/) provide mappings between the minified code produced by bundlers or minifiers and the actual source code a developer works with. This way, the source maps enable support for debugging the code during its execution. The Kotlin/JS Gradle plugin automatically generates source maps for the project builds, making them available without any additional configuration. Debug in browser ---------------- Most modern browsers provide tools that allow inspecting the page content and debugging the code that executes on it. Refer to your browser's documentation for more details. To debug Kotlin/JS in the browser: 1. Run the project by calling one of the available *run* Gradle tasks, for example, `browserDevelopmentRun` or `jsBrowserDevelopmentRun` in a multiplatform project. Learn more about [running Kotlin/JS](running-kotlin-js#run-the-browser-target). 2. Navigate to the page in the browser and launch its developer tools (for example, by right-clicking and selecting the **Inspect** action). Learn how to [find the developer tools](https://balsamiq.com/support/faqs/browserconsole/) in popular browsers. 3. If your program is logging information to the console, navigate to the **Console** tab to see this output. Depending on your browser, these logs can reference the Kotlin source files and lines they come from: ![Chrome DevTools console](https://kotlinlang.org/docs/images/devtools-console.png "Chrome DevTools console")4. Click the file reference on the right to navigate to the corresponding line of code. Alternatively, you can manually switch to the **Sources** tab and find the file you need in the file tree. Navigating to the Kotlin file shows you the regular Kotlin code (as opposed to minified JavaScript): ![Debugging in Chrome DevTools](https://kotlinlang.org/docs/images/devtools-sources.png "Debugging in Chrome DevTools")You can now start debugging the program. Set a breakpoint by clicking on one of the line numbers. The developer tools even support setting breakpoints within a statement. As with regular JavaScript code, any set breakpoints will persist across page reloads. This also makes it possible to debug Kotlin's `main()` method which is executed when the script is loaded for the first time. Debug in the IDE ---------------- [IntelliJ IDEA Ultimate](https://www.jetbrains.com/idea/) provides a powerful set of tools for debugging code during development. For debugging Kotlin/JS in IntelliJ IDEA, you'll need a **JavaScript Debug** configuration. To add such a debug configuration: 1. Go to **Run | Edit Configurations**. 2. Click **+** and select **JavaScript Debug**. 3. Specify the configuration **Name** and provide the **URL** on which the project runs (`http://localhost:8080` by default). ![JavaScript debug configuration](https://kotlinlang.org/docs/images/debug-config.png "JavaScript debug configuration")4. Save the configuration. Learn more about [setting up JavaScript debug configurations](https://www.jetbrains.com/help/idea/configuring-javascript-debugger.html). Now you're ready to debug your project! 1. Run the project by calling one of the available *run* Gradle tasks, for example, `browserDevelopmentRun` or `jsBrowserDevelopmentRun` in a multiplatform project. Learn more about [running Kotlin/JS](running-kotlin-js#run-the-browser-target). 2. Start the debugging session by running the JavaScript debug configuration you've created previously: ![JavaScript debug configuration](https://kotlinlang.org/docs/images/debug-config-run.png "JavaScript debug configuration")3. You can see the console output of your program in the **Debug** window in IntelliJ IDEA. The output items reference the Kotlin source files and lines they come from: ![JavaScript debug output in the IDE](https://kotlinlang.org/docs/images/ide-console-output.png "JavaScript debug output in the IDE")4. Click the file reference on the right to navigate to the corresponding line of code. You can now start debugging the program using the whole set of tools that the IDE offers: breakpoints, stepping, expression evaluation, and more. Learn more about [debugging in IntelliJ IDEA](https://www.jetbrains.com/help/idea/debugging-javascript-in-chrome.html). Debug in Node.js ---------------- If your project targets Node.js, you can debug it in this runtime. To debug a Kotlin/JS application targeting Node.js: 1. Build the project by running the `build` Gradle task. 2. Find the resulting `.js` file for Node.js in the `build/js/packages/your-module/kotlin/` directory inside your project's directory. 3. Debug it in Node.js as described in the [Node.js Debugging Guide](https://nodejs.org/en/docs/guides/debugging-getting-started/#jetbrains-webstorm-2017-1-and-other-jetbrains-ides). What's next? ------------ Now that you know how to start debug sessions with your Kotlin/JS project, learn to make efficient use of the debugging tools: * Learn how to [debug JavaScript in Google Chrome](https://developer.chrome.com/docs/devtools/javascript/) * Get familiar with [IntelliJ IDEA JavaScript debugger](https://www.jetbrains.com/help/idea/debugging-javascript-in-chrome.html) * Learn how to [debug in Node.js](https://nodejs.org/en/docs/guides/debugging-getting-started/). If you run into any problems ---------------------------- If you face any issues with debugging Kotlin/JS, please report them to our issue tracker, [YouTrack](https://kotl.in/issue) Last modified: 10 January 2023 [Development server and continuous compilation](dev-server-continuous-compilation) [Run tests in Kotlin/JS](js-running-tests) kotlin What's new in Kotlin 1.4.30 What's new in Kotlin 1.4.30 =========================== *[Release date: 3 February 2021](releases#release-details)* Kotlin 1.4.30 offers preview versions of new language features, promotes the new IR backend of the Kotlin/JVM compiler to Beta, and ships various performance and functional improvements. You can also learn about new features in [this blog post](https://blog.jetbrains.com/kotlin/2021/01/kotlin-1-4-30-released/). Language features ----------------- Kotlin 1.5.0 is going to deliver new language features – JVM records support, sealed interfaces, and Stable inline classes. In Kotlin 1.4.30, you can try these features and improvements in preview mode. We would be very grateful if you share your feedback with us in the corresponding YouTrack tickets, as that will allow us to address it before the release of 1.5.0. * [JVM records support](#jvm-records-support) * [Sealed interfaces](#sealed-interfaces) and [sealed class improvements](#package-wide-sealed-class-hierarchies) * [Improved inline classes](#improved-inline-classes) To enable these language features and improvements in preview mode, you need to opt in by adding specific compiler options. See the sections below for details. Learn more about the new features preview in [this blog post](https://blog.jetbrains.com/kotlin/2021/01/new-language-features-preview-in-kotlin-1-4-30). ### JVM records support The [JDK 16 release](https://openjdk.java.net/projects/jdk/16/) includes plans to stabilize a new Java class type called [record](https://openjdk.java.net/jeps/395). To provide all the benefits of Kotlin and maintain its interoperability with Java, Kotlin is introducing experimental record class support. You can use record classes that are declared in Java just like classes with properties in Kotlin. No additional steps are required. Starting with 1.4.30, you can declare the record class in Kotlin using the `@JvmRecord` annotation for a [data class](data-classes): ``` @JvmRecord data class User(val name: String, val age: Int) ``` To try the preview version of JVM records, add the compiler options `-Xjvm-enable-preview` and `-language-version 1.5`. We're continuing to work on JVM records support, and we would be very grateful if you would share your feedback with us using this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-42430). Learn more about implementation, restrictions, and the syntax in [KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/jvm-records.md). ### Sealed interfaces In Kotlin 1.4.30, we're shipping the prototype of *sealed interfaces*. They complement sealed classes and make it possible to build more flexible restricted class hierarchies. They can serve as "internal" interfaces that cannot be implemented outside the same module. You can rely on that fact, for example, to write exhaustive `when` expressions. ``` sealed interface Polygon class Rectangle(): Polygon class Triangle(): Polygon // when() is exhaustive: no other polygon implementations can appear // after the module is compiled fun draw(polygon: Polygon) = when (polygon) { is Rectangle -> // ... is Triangle -> // ... } ``` Another use-case: with sealed interfaces, you can inherit a class from two or more sealed superclasses. ``` sealed interface Fillable { fun fill() } sealed interface Polygon { val vertices: List<Point> } class Rectangle(override val vertices: List<Point>): Fillable, Polygon { override fun fill() { /*...*/ } } ``` To try the preview version of sealed interfaces, add the compiler option `-language-version 1.5`. Once you switch to this version, you'll be able to use the `sealed` modifier on interfaces. We would be very grateful if you would share your feedback with us using this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-42433). [Learn more about sealed interfaces](sealed-classes). ### Package-wide sealed class hierarchies Sealed classes can now form more flexible hierarchies. They can have subclasses in all files of the same compilation unit and the same package. Previously, all subclasses had to appear in the same file. Direct subclasses may be top-level or nested inside any number of other named classes, named interfaces, or named objects. The subclasses of a sealed class must have a name that is properly qualified – they cannot be local nor anonymous objects. To try package-wide hierarchies of sealed classes, add the compiler option `-language-version 1.5`. We would be very grateful if you would share your feedback with us using this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-42433). [Learn more about package-wide hierarchies of sealed classes](sealed-classes#location-of-direct-subclasses). ### Improved inline classes Kotlin 1.4.30 promotes [inline classes](inline-classes) to [Beta](components-stability) and brings the following features and improvements to them: * Since inline classes are [value-based](https://docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/doc-files/ValueBased.html), you can define them using the `value` modifier. The `inline` and `value` modifiers are now equivalent to each other. In future Kotlin versions, we're planning to deprecate the `inline` modifier. From now on, Kotlin requires the `@JvmInline` annotation before a class declaration for the JVM backend: ``` inline class Name(private val s: String) value class Name(private val s: String) // For JVM backends @JvmInline value class Name(private val s: String) ``` * Inline classes can have `init` blocks. You can add code to be executed right after the class is instantiated: ``` @JvmInline value class Negative(val x: Int) { init { require(x < 0) { } } } ``` * Calling functions with inline classes from Java code: before Kotlin 1.4.30, you couldn't call functions that accept inline classes from Java because of mangling. From now on, you can disable mangling manually. To call such functions from Java code, you should add the `@JvmName` annotation before the function declaration: ``` inline class UInt(val x: Int) fun compute(x: Int) { } @JvmName("computeUInt") fun compute(x: UInt) { } ``` * In this release, we've changed the mangling scheme for functions to fix the incorrect behavior. These changes led to ABI changes. Starting with 1.4.30, the Kotlin compiler uses a new mangling scheme by default. Use the `-Xuse-14-inline-classes-mangling-scheme` compiler flag to force the compiler to use the old 1.4.0 mangling scheme and preserve binary compatibility. Kotlin 1.4.30 promotes inline classes to Beta and we are planning to make them Stable in future releases. We'd be very grateful if you would share your feedback with us using this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-42434). To try the preview version of inline classes, add the compiler option `-Xinline-classes` or `-language-version 1.5`. Learn more about the mangling algorithm in [KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/inline-classes.md). [Learn more about inline classes](inline-classes). Kotlin/JVM ---------- ### JVM IR compiler backend reaches Beta The [IR-based compiler backend](whatsnew14#unified-backends-and-extensibility) for Kotlin/JVM, which was presented in 1.4.0 in [Alpha](components-stability), has reached Beta. This is the last pre-stable level before the IR backend becomes the default for the Kotlin/JVM compiler. We're now dropping the restriction on consuming binaries produced by the IR compiler. Previously, you could use code compiled by the new JVM IR backend only if you had enabled the new backend. Starting from 1.4.30, there is no such limitation, so you can use the new backend to build components for third-party use, such as libraries. Try the Beta version of the new backend and share your feedback in our [issue tracker](https://kotl.in/issue). To enable the new JVM IR backend, add the following lines to the project's configuration file: * In Gradle: ``` tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile::class) { kotlinOptions.useIR = true } ``` ``` tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile) { kotlinOptions.useIR = true } ``` * In Maven: ``` <configuration> <args> <arg>-Xuse-ir</arg> </args> </configuration> ``` Learn more about the changes that the JVM IR backend brings in [this blog post](https://blog.jetbrains.com/kotlin/2021/01/the-jvm-backend-is-in-beta-let-s-make-it-stable-together). Kotlin/Native ------------- ### Performance improvements Kotlin/Native has received a variety of performance improvements in 1.4.30, which has resulted in faster compilation times. For example, the time required to rebuild the framework in the [Networking and data storage with Kotlin Multiplatform Mobile](https://github.com/kotlin-hands-on/kmm-networking-and-data-storage/tree/final) sample has decreased from 9.5 seconds (in 1.4.10) to 4.5 seconds (in 1.4.30). ### Apple watchOS 64-bit simulator target The x86 simulator target has been deprecated for watchOS since version 7.0. To keep up with the latest watchOS versions, Kotlin/Native has the new target `watchosX64` for running the simulator on 64-bit architecture. ### Support for Xcode 12.2 libraries We have added support for the new libraries delivered with Xcode 12.2. You can now use them from Kotlin code. Kotlin/JS --------- ### Lazy initialization of top-level properties The [IR backend](js-ir-compiler) for Kotlin/JS is receiving a prototype implementation of lazy initialization for top-level properties. This reduces the need to initialize all top-level properties when the application starts, and it should significantly improve application start-up times. We'll keep working on the lazy initialization, and we ask you to try the current prototype and share your thoughts and results in this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-44320) or the [`#javascript`](https://kotlinlang.slack.com/archives/C0B8L3U69) channel in the official [Kotlin Slack](https://kotlinlang.slack.com) (get an invite [here](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)). To use the lazy initialization, add the `-Xir-property-lazy-initialization` compiler option when compiling the code with the JS IR compiler. Gradle project improvements --------------------------- ### Support the Gradle configuration cache Starting with 1.4.30, the Kotlin Gradle plugin supports the [configuration cache](https://docs.gradle.org/current/userguide/configuration_cache.html) feature. It speeds up the build process: once you run the command, Gradle executes the configuration phase and calculates the task graph. Gradle caches the result and reuses it for subsequent builds. To start using this feature, you can [use the Gradle command](https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:usage) or [set up the IntelliJ based IDE](https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:ide:intellij). Standard library ---------------- ### Locale-agnostic API for upper/lowercasing text This release introduces the experimental locale-agnostic API for changing the case of strings and characters. The current `toLowerCase()`, `toUpperCase()`, `capitalize()`, `decapitalize()` API functions are locale-sensitive. This means that different platform locale settings can affect code behavior. For example, in the Turkish locale, when the string "kotlin" is converted using `toUpperCase`, the result is "KOTLİN", not "KOTLIN". ``` // current API println("Needs to be capitalized".toUpperCase()) // NEEDS TO BE CAPITALIZED // new API println("Needs to be capitalized".uppercase()) // NEEDS TO BE CAPITALIZED ``` Kotlin 1.4.30 provides the following alternatives: * For `String` functions: | **Earlier versions** | **1.4.30 alternative** | | --- | --- | | `String.toUpperCase()` | `String.uppercase()` | | `String.toLowerCase()` | `String.lowercase()` | | `String.capitalize()` | `String.replaceFirstChar { it.uppercase() }` | | `String.decapitalize()` | `String.replaceFirstChar { it.lowercase() }` | * For `Char` functions: | **Earlier versions** | **1.4.30 alternative** | | --- | --- | | `Char.toUpperCase()` | `Char.uppercaseChar(): Char``Char.uppercase(): String` | | `Char.toLowerCase()` | `Char.lowercaseChar(): Char``Char.lowercase(): String` | | `Char.toTitleCase()` | `Char.titlecaseChar(): Char``Char.titlecase(): String` | See the full list of changes to the text processing functions in [KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/locale-agnostic-string-conversions.md). ### Clear Char-to-code and Char-to-digit conversions The current `Char` to numbers conversion functions, which return UTF-16 codes expressed in different numeric types, are often confused with the similar String-to-Int conversion, which returns the numeric value of a string: ``` "4".toInt() // returns 4 '4'.toInt() // returns 52 // and there was no common function that would return the numeric value 4 for Char '4' ``` To avoid this confusion we've decided to separate `Char` conversions into two following sets of clearly named functions: * Functions to get the integer code of `Char` and to construct `Char` from the given code: ``` fun Char(code: Int): Char fun Char(code: UShort): Char val Char.code: Int ``` * Functions to convert `Char` to the numeric value of the digit it represents: ``` fun Char.digitToInt(radix: Int): Int fun Char.digitToIntOrNull(radix: Int): Int? ``` * An extension function for `Int` to convert the non-negative single digit it represents to the corresponding `Char` representation: ``` fun Int.digitToChar(radix: Int): Char ``` See more details in [KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/char-int-conversions.md). Serialization updates --------------------- Along with Kotlin 1.4.30, we are releasing `kotlinx.serialization` [1.1.0-RC](https://github.com/Kotlin/kotlinx.serialization/releases/tag/v1.1.0-RC), which includes some new features: * Inline classes serialization support * Unsigned primitive type serialization support ### Inline classes serialization support Starting with Kotlin 1.4.30, you can make inline classes [serializable](serialization): ``` @Serializable inline class Color(val rgb: Int) ``` The serialization framework does not box serializable inline classes when they are used in other serializable classes. Learn more in the `kotlinx.serialization` [docs](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/inline-classes.md#serializable-inline-classes). ### Unsigned primitive type serialization support Starting from 1.4.30, you can use standard JSON serializers of [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) for unsigned primitive types: `UInt`, `ULong`, `UByte`, and `UShort`: ``` @Serializable class Counter(val counted: UByte, val description: String) fun main() { val counted = 239.toUByte() println(Json.encodeToString(Counter(counted, "tries"))) } ``` Learn more in the `kotlinx.serialization` [docs](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/inline-classes.md#unsigned-types-support-json-only). Last modified: 10 January 2023 [What's new in Kotlin 1.5.0](whatsnew15) [What's new in Kotlin 1.4.20](whatsnew1420)
programming_docs
kotlin Enum classes Enum classes ============ The most basic use case for enum classes is the implementation of type-safe enums: ``` enum class Direction { NORTH, SOUTH, WEST, EAST } ``` Each enum constant is an object. Enum constants are separated by commas. Since each enum is an instance of the enum class, it can be initialized as: ``` enum class Color(val rgb: Int) { RED(0xFF0000), GREEN(0x00FF00), BLUE(0x0000FF) } ``` Anonymous classes ----------------- Enum constants can declare their own anonymous classes with their corresponding methods, as well as with overriding base methods. ``` enum class ProtocolState { WAITING { override fun signal() = TALKING }, TALKING { override fun signal() = WAITING }; abstract fun signal(): ProtocolState } ``` If the enum class defines any members, separate the constant definitions from the member definitions with a semicolon. Implementing interfaces in enum classes --------------------------------------- An enum class can implement an interface (but it cannot derive from a class), providing either a common implementation of interface members for all the entries, or separate implementations for each entry within its anonymous class. This is done by adding the interfaces you want to implement to the enum class declaration as follows: ``` import java.util.function.BinaryOperator import java.util.function.IntBinaryOperator //sampleStart enum class IntArithmetics : BinaryOperator<Int>, IntBinaryOperator { PLUS { override fun apply(t: Int, u: Int): Int = t + u }, TIMES { override fun apply(t: Int, u: Int): Int = t * u }; override fun applyAsInt(t: Int, u: Int) = apply(t, u) } //sampleEnd fun main() { val a = 13 val b = 31 for (f in IntArithmetics.values()) { println("$f($a, $b) = ${f.apply(a, b)}") } } ``` All enum classes implement the [Comparable](../api/latest/jvm/stdlib/kotlin/-comparable/index) interface by default. Constants in the enum class are defined in the natural order. For more information, see [Ordering](collection-ordering). Working with enum constants --------------------------- Enum classes in Kotlin have synthetic methods for listing the defined enum constants and getting an enum constant by its name. The signatures of these methods are as follows (assuming the name of the enum class is `EnumClass`): ``` EnumClass.valueOf(value: String): EnumClass EnumClass.values(): Array<EnumClass> ``` The `valueOf()` method throws an `IllegalArgumentException` if the specified name does not match any of the enum constants defined in the class. You can access the constants in an enum class in a generic way using the `enumValues<T>()` and `enumValueOf<T>()` functions: ``` enum class RGB { RED, GREEN, BLUE } inline fun <reified T : Enum<T>> printAllValues() { print(enumValues<T>().joinToString { it.name }) } printAllValues<RGB>() // prints RED, GREEN, BLUE ``` Every enum constant has properties for obtaining its name and position (starting with 0) in the enum class declaration: ``` val name: String val ordinal: Int ``` Last modified: 10 January 2023 [Nested and inner classes](nested-classes) [Inline classes](inline-classes) kotlin Get started with Kotlin custom scripting – tutorial Get started with Kotlin custom scripting – tutorial =================================================== *Kotlin scripting* is the technology that enables executing Kotlin code as scripts without prior compilation or packaging into executables. For an overview of Kotlin scripting with examples, check out the talk [Implementing the Gradle Kotlin DSL](https://kotlinconf.com/2019/talks/video/2019/126701/) by Rodrigo Oliveira from KotlinConf'19. In this tutorial, you'll create a Kotlin scripting project that executes arbitrary Kotlin code with Maven dependencies. You'll be able to execute scripts like this: ``` @file:Repository("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") @file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.3") import kotlinx.html.* import kotlinx.html.stream.* import kotlinx.html.attributes.* val addressee = "World" print( createHTML().html { body { h1 { +"Hello, $addressee!" } } } ) ``` The specified Maven dependency (`kotlinx-html-jvm` for this example) will be resolved from the specified Maven repository or local cache during execution and used for the rest of the script. Project structure ----------------- A minimal Kotlin custom scripting project contains two parts: * *Script definition* – a set of parameters and configurations that define how this script type should be recognized, handled, compiled, and executed. * *Scripting host* – an application or component that handles script compilation and execution – actually running scripts of this type. With all of this in mind, it's best to split the project into two modules. Before you start ---------------- Download and install the latest version of [IntelliJ IDEA](https://www.jetbrains.com/idea/download/index.html). Create a project ---------------- 1. In IntelliJ IDEA, select **File** | **New** | **Project**. 2. In the panel on the left, select **New Project**. 3. Name the new project and change its location if necessary. 4. From the **Language** list, select **Kotlin**. 5. Select the **Gradle** build system. 6. From the **JDK list**, select the [JDK](https://www.oracle.com/java/technologies/downloads/) that you want to use in your project. * If the JDK is installed on your computer, but not defined in the IDE, select **Add JDK** and specify the path to the JDK home directory. * If you don't have the necessary JDK on your computer, select **Download JDK**. 7. Select the Kotlin or Gradle language for the **Gradle DSL**. 8. Click **Create**. ![Create a root project for custom Kotlin scripting](https://kotlinlang.org/docs/images/script-deps-create-root-project.png "Create a root project for custom Kotlin scripting")Add scripting modules --------------------- Now you have an empty Kotlin/JVM Gradle project. Add the required modules, script definition and scripting host: 1. In IntelliJ IDEA, select **File | New | Module**. 2. In the panel on the left, select **New Module**. This module will be the script definition. 3. Name the new module and change its location if necessary. 4. From the **Language** list, select **Java**. 5. Select the **Gradle** build system and Kotlin for the **Gradle DSL** if you want to write the build script in Kotlin. 6. As a module's parent, select the root module. 7. Click **Create**. ![Create script definition module](https://kotlinlang.org/docs/images/script-deps-module-definition.png "Create script definition module") 8. In the module's `build.gradle(.kts)` file, remove the `version` of the Kotlin Gradle plugin. It is already in the root project's build script. 9. Repeat previous steps one more time to create a module for the scripting host. The project should have the following structure: ![Custom scripting project structure](https://kotlinlang.org/docs/images/script-deps-project-structure.png "Custom scripting project structure")You can find an example of such a project and more Kotlin scripting examples in the [kotlin-script-examples GitHub repository](https://github.com/Kotlin/kotlin-script-examples/tree/master/jvm/basic/jvm-maven-deps). Create a script definition -------------------------- First, define the script type: what developers can write in scripts of this type and how it will be handled. In this tutorial, this includes support for the `@Repository` and `@DependsOn` annotations in the scripts. 1. In the script definition module, add the dependencies on the Kotlin scripting components in the `dependencies` block of `build.gradle(.kts)`. These dependencies provide the APIs you will need for the script definition: ``` dependencies { implementation("org.jetbrains.kotlin:kotlin-scripting-common") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm") implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies") implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven") // coroutines dependency is required for this particular definition implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } ``` ``` dependencies { implementation 'org.jetbrains.kotlin:kotlin-scripting-common' implementation 'org.jetbrains.kotlin:kotlin-scripting-jvm' implementation 'org.jetbrains.kotlin:kotlin-scripting-dependencies' implementation 'org.jetbrains.kotlin:kotlin-scripting-dependencies-maven' // coroutines dependency is required for this particular definition implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.4' } ``` 2. Create the `src/main/kotlin/` directory in the module and add a Kotlin source file, for example, `scriptDef.kt`. 3. In `scriptDef.kt`, create a class. It will be a superclass for scripts of this type, so declare it `abstract` or `open`. ``` // abstract (or open) superclass for scripts of this type abstract class ScriptWithMavenDeps ``` This class will also serve as a reference to the script definition later. 4. To make the class a script definition, mark it with the `@KotlinScript` annotation. Pass two parameters to the annotation: * `fileExtension` – a string ending with `.kts` that defines a file extension for scripts of this type. * `compilationConfiguration` – a Kotlin class that extends `ScriptCompilationConfiguration` and defines the compilation specifics for this script definition. You'll create it in the next step. ``` // @KotlinScript annotation marks a script definition class @KotlinScript( // File extension for the script type fileExtension = "scriptwithdeps.kts", // Compilation configuration for the script type compilationConfiguration = ScriptWithMavenDepsConfiguration::class ) abstract class ScriptWithMavenDeps object ScriptWithMavenDepsConfiguration: ScriptCompilationConfiguration() ``` 5. Define the script compilation configuration as shown below. ``` object ScriptWithMavenDepsConfiguration : ScriptCompilationConfiguration( { // Implicit imports for all scripts of this type defaultImports(DependsOn::class, Repository::class) jvm { // Extract the whole classpath from context classloader and use it as dependencies dependenciesFromCurrentContext(wholeClasspath = true) } // Callbacks refineConfiguration { // Process specified annotations with the provided handler onAnnotations(DependsOn::class, Repository::class, handler = ::configureMavenDepsOnAnnotations) } } ) ``` The `configureMavenDepsOnAnnotations` function is as follows: ``` // Handler that reconfigures the compilation on the fly fun configureMavenDepsOnAnnotations(context: ScriptConfigurationRefinementContext): ResultWithDiagnostics<ScriptCompilationConfiguration> { val annotations = context.collectedData?.get(ScriptCollectedData.collectedAnnotations)?.takeIf { it.isNotEmpty() } ?: return context.compilationConfiguration.asSuccess() return runBlocking { resolver.resolveFromScriptSourceAnnotations(annotations) }.onSuccess { context.compilationConfiguration.with { dependencies.append(JvmDependency(it)) }.asSuccess() } } private val resolver = CompoundDependenciesResolver(FileSystemDependenciesResolver(), MavenDependenciesResolver()) ``` You can find the full code [here](https://github.com/Kotlin/kotlin-script-examples/blob/master/jvm/basic/jvm-maven-deps/script/src/main/kotlin/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt). Create a scripting host ----------------------- The next step is creating the scripting host – the component that handles the script execution. 1. In the scripting host module, add the dependencies in the `dependencies` block of `build.gradle(.kts)`: * Kotlin scripting components that provide the APIs you need for the scripting host * The script definition module you created previously ``` dependencies { implementation("org.jetbrains.kotlin:kotlin-scripting-common") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host") implementation(project(":script-definition")) // the script definition module } ``` ``` dependencies { implementation 'org.jetbrains.kotlin:kotlin-scripting-common' implementation 'org.jetbrains.kotlin:kotlin-scripting-jvm' implementation 'org.jetbrains.kotlin:kotlin-scripting-jvm-host' implementation project(':script-definition') // the script definition module } ``` 2. Create the `src/main/kotlin/` directory in the module and add a Kotlin source file, for example, `host.kt`. 3. Define the `main` function for the application. In its body, check that it has one argument – the path to the script file – and execute the script. You'll define the script execution in a separate function `evalFile` in the next step. Declare it empty for now. `main` can look like this: ``` fun main(vararg args: String) { if (args.size != 1) { println("usage: <app> <script file>") } else { val scriptFile = File(args[0]) println("Executing script $scriptFile") evalFile(scriptFile) } } ``` 4. Define the script evaluation function. This is where you'll use the script definition. Obtain it by calling `createJvmCompilationConfigurationFromTemplate` with the script definition class as a type parameter. Then call `BasicJvmScriptingHost().eval`, passing it the script code and its compilation configuration. `eval` returns an instance of `ResultWithDiagnostics`, so set it as your function's return type. ``` fun evalFile(scriptFile: File): ResultWithDiagnostics<EvaluationResult> { val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<ScriptWithMavenDeps>() return BasicJvmScriptingHost().eval(scriptFile.toScriptSource(), compilationConfiguration, null) } ``` 5. Adjust the `main` function to print information about the script execution: ``` fun main(vararg args: String) { if (args.size != 1) { println("usage: <app> <script file>") } else { val scriptFile = File(args[0]) println("Executing script $scriptFile") val res = evalFile(scriptFile) res.reports.forEach { if (it.severity > ScriptDiagnostic.Severity.DEBUG) { println(" : ${it.message}" + if (it.exception == null) "" else ": ${it.exception}") } } } } ``` You can find the full code [here](https://github.com/Kotlin/kotlin-script-examples/blob/master/jvm/basic/jvm-maven-deps/host/src/main/kotlin/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/host/host.kt) Run scripts ----------- To check how your scripting host works, prepare a script to execute and a run configuration. 1. Create the file `html.scriptwithdeps.kts` with the following content in the project root directory: ``` @file:Repository("https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven") @file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.3") import kotlinx.html.*; import kotlinx.html.stream.*; import kotlinx.html.attributes.* val addressee = "World" print( createHTML().html { body { h1 { +"Hello, $addressee!" } } } ) ``` It uses functions from the `kotlinx-html-jvm` library which is referenced in the `@DependsOn` annotation argument. 2. Create a run configuration that starts the scripting host and executes this file: 1. Open `host.kt` and navigate to the `main` function. It has a **Run** gutter icon on the left. 2. Right-click the gutter icon and select **Modify Run Configuration**. 3. In the **Create Run Configuration** dialog, add the script file name to **Program arguments** and click **OK**. ![Scripting host run configuration](https://kotlinlang.org/docs/images/script-deps-run-config.png "Scripting host run configuration") 3. Run the created configuration. You'll see how the script is executed, resolving the dependency on `kotlinx-html-jvm` in the specified repository and printing the results of calling its functions: ``` <html> <body> <h1>Hello, World!</h1> </body> </html> ``` Resolving dependencies may take some time on the first run. Subsequent runs will complete much faster because they use downloaded dependencies from the local Maven repository. What's next? ------------ Once you've created a simple Kotlin scripting project, find more information on this topic: * Read the [Kotlin scripting KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md) * Browse more [Kotlin scripting examples](https://github.com/Kotlin/kotlin-script-examples) * Watch the talk [Implementing the Gradle Kotlin DSL](https://kotlinconf.com/2019/talks/video/2019/126701/) by Rodrigo Oliveira Last modified: 10 January 2023 [Kotlin/Native FAQ](native-faq) [Kotlin releases](releases) kotlin Stress testing and model checking Stress testing and model checking ================================= Lincheck provides two testing strategies: stress testing and model checking. Learn what happens under the hood of both testing strategies using the `Counter` example from the [previous step](introduction): ``` class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } ``` Stress testing -------------- ### Write a stress test Create a concurrent stress test for the `Counter`, following these steps: 1. Create the `CounterTest` class. 2. In this class, add the field `c` of the `Counter` type, creating an instance in the constructor. 3. List the counter operations and mark them with the `@Operation` annotation, delegating their implementations to `c`. 4. Specify the stress testing strategy using `StressOptions()`. 5. Invoke the `StressOptions.check()` function to run the test. The resulting code will look like this: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.strategy.stress.* import org.junit.* class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class CounterTest { private val c = Counter() // Initial state // Operations on the Counter @Operation fun inc() = c.inc() @Operation fun get() = c.get() @Test // Run the test fun stressTest() = StressOptions().check(this::class) } ``` ### How stress testing works At first, Lincheck generates a set of concurrent scenarios using the operations marked with `@Operation`. Then it launches native threads, synchronizing them at the beginning to guarantee that operations start simultaneously. Finally, Lincheck executes each scenario on these native threads multiple times, expecting to hit an interleaving that produces incorrect results. The figure below shows a high-level scheme of how Lincheck may execute generated scenarios: ![Stress execution of the Counter](https://kotlinlang.org/docs/images/counter-stress.png "Stress execution of the Counter") Model checking -------------- The main concern regarding stress testing is that you may spend hours trying to understand how to reproduce the found bug. To help you with that, Lincheck supports bounded model checking, which automatically provides an interleaving for reproducing bugs. A model checking test is constructed the same way as the stress test. Just replace the `StressOptions()` that specify the testing strategy with `ModelCheckingOptions()`. ### Write a model checking test To change the stress testing strategy to model checking, replace `StressOptions()` with `ModelCheckingOptions()` in your test: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* import org.junit.* class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class CounterTest { private val c = Counter() // Initial state // Operations on the Counter @Operation fun inc() = c.inc() @Operation fun get() = c.get() @Test // Run the test fun modelCheckingTest() = ModelCheckingOptions().check(this::class) } ``` ### How model checking works Most bugs in complicated concurrent algorithms can be reproduced with classic interleavings, switching the execution from one thread to another. Besides, model checkers for weak memory models are very complicated, so Lincheck uses a bounded model checking under the *sequential consistency memory model*. In short, Lincheck analyzes all interleavings, starting with one context switch, then two, continuing the process until the specified number of interleaving is examined. This strategy allows finding an incorrect schedule with the lowest possible number of context switches, making further bug investigation easier. To control the execution, Lincheck inserts special switch points into the testing code. These points identify where a context switch can be performed. Essentially, these are shared memory accesses, such as field and array element reads or updates in the JVM, as well as `wait/notify` and `park/unpark` calls. To insert a switch point, Lincheck transforms the testing code on the fly using the ASM framework, adding internal function invocations to the existing code. As the model checking strategy controls the execution, Lincheck can provide the trace that leads to the invalid interleaving, which is extremely helpful in practice. You can see the example of trace for the incorrect execution of the `Counter` in the [Write your first test with Lincheck](introduction#trace-the-invalid-execution) tutorial. Which testing strategy is better? --------------------------------- The *model checking strategy* is preferable for finding bugs under the sequentially consistent memory model since it ensures better coverage and provides a failing execution trace if an error is found. Although *stress testing* doesn't guarantee any coverage, checking algorithms for bugs introduced by low-level effects, such as a missed `volatile` modifier, is still helpful. Stress testing is also a great help in discovering rare bugs that require many context switches to reproduce, and it's impossible to analyze them all due to the current restrictions in the model checking strategy. Configure the testing strategy ------------------------------ To configure the testing strategy, set options in the `<TestingMode>Options` class. 1. Set the options for scenario generation and execution for the `CounterTest`: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.strategy.stress.* import org.jetbrains.kotlinx.lincheck.verifier.* import org.junit.* class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class CounterTest { private val c = Counter() @Operation fun inc() = c.inc() @Operation fun get() = c.get() @Test fun stressTest() = StressOptions() // Stress testing options: .actorsBefore(2) // Number of operations before the parallel part .threads(2) // Number of threads in the parallel part .actorsPerThread(2) // Number of operations in each thread of the parallel part .actorsAfter(1) // Number of operations after the parallel part .iterations(100) // Generate 100 random concurrent scenarios .invocationsPerIteration(1000) // Run each generated scenario 1000 times .check(this::class) // Run the test } ``` 2. Run `stressTest()` again, Lincheck will generate scenarios similar to the one below: ``` Init part: [inc(), inc()] Parallel part: | get() | inc() | | inc() | get() | Post part: [inc()] ``` Here, there are two operations before the parallel part, two threads for each of the two operations, followed after that by a single operation in the end. You can configure your model checking tests in the same way. Scenario minimization --------------------- You may already have noticed that detected errors are usually represented with a scenario smaller than the specified in the test configuration. Lincheck tries to minimize the error, actively removing an operation while it's possible to keep the test from failing. Here's the minimized scenario for the counter test above: ``` = Invalid execution results = Parallel part: | inc(): 1 | inc(): 1 | ``` As it's easier to analyze smaller scenarios, scenario minimization is enabled by default. To disable this feature, add `minimizeFailedScenario(false)` to the `[Stress, ModelChecking]Options` configuration. Logging data structure states ----------------------------- Another useful feature for debugging is *state logging*. When analyzing an interleaving that leads to an error, you usually draw the data structure changes on a sheet of paper, changing the state after each event. To automize this procedure, you can provide a special method that returns a `String` representation of the data structure, so Lincheck prints the state representation after each event in the interleaving that modifies the data structure. For this, define a method that doesn't take arguments and is marked with the `@StateRepresentation` annotation. The method should be thread-safe, non-blocking, and never modify the data structure. 1. In the `Counter` example, the `String` representation is simply the value of the counter. Thus, to print the counter states in the trace, add the `stateRepresentation()` function to the `CounterTest`: ``` import org.jetbrains.kotlinx.lincheck.annotations.* import org.jetbrains.kotlinx.lincheck.check import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.* import org.junit.Test class Counter { @Volatile private var value = 0 fun inc(): Int = ++value fun get() = value } class CounterTest { private val c = Counter() @Operation fun inc() = c.inc() @Operation fun get() = c.get() @StateRepresentation fun stateRepresentation() = c.get().toString() @Test fun modelCheckingTest() = ModelCheckingOptions().check(this::class) } ``` 2. Run the `modelCheckingTest()` now and check the states of the `Counter` printed at the switch points that modify the counter state (they start with `STATE:`): ``` = Invalid execution results = STATE: 0 Parallel part: | inc(): 1 | inc(): 1 | STATE: 1 = The following interleaving leads to the error = Parallel part trace: | | inc() | | | inc(): 1 at CounterTest.inc(CounterTest.kt:42) | | | value.READ: 0 at Counter.inc(CounterTest.kt:35) | | | switch | | inc(): 1 | | | STATE: 1 | | | thread is finished | | | | value.WRITE(1) at Counter.inc(CounterTest.kt:35) | | | STATE: 1 | | | value.READ: 1 at Counter.inc(CounterTest.kt:35) | | | result: 1 | | | thread is finished | ``` In case of stress testing, Lincheck prints the state representation right before and after the parallel part of the scenario, as well as at the end. Next step --------- Learn how to [configure arguments passed to the operations](operation-arguments) and when it can be useful. See also -------- See how to optimize and increase coverage of the model checking strategy using [modular testing](modular-testing). Last modified: 10 January 2023 [Write your first test with Lincheck](introduction) [Operation arguments](operation-arguments)
programming_docs
kotlin Kotlin/Native as a dynamic library – tutorial Kotlin/Native as a dynamic library – tutorial ============================================= Learn how you can use the Kotlin/Native code from existing native applications or libraries. For this, you need to compile the Kotlin code into a dynamic library, `.so`, `.dylib`, and `.dll`. Kotlin/Native also has tight integration with Apple technologies. The [Kotlin/Native as an Apple Framework](apple-framework) tutorial explains how to compile Kotlin code into a framework for Swift and Objective-C. In this tutorial, you will: * [Compile Kotlin code to a dynamic library](#create-a-kotlin-library) * [Examine generated C headers](#generated-headers-file) * [Use the Kotlin dynamic library from C](#use-generated-headers-from-c) * Compile and run the example on [Linux and Mac](#compile-and-run-the-example-on-linux-and-macos) and [Windows](#compile-and-run-the-example-on-windows) Create a Kotlin library ----------------------- Kotlin/Native compiler can produce a dynamic library out of the Kotlin code. A dynamic library often comes with a header file, a `.h` file, which you will use to call the compiled code from C. The best way to understand these techniques is to try them out. First, create a first tiny Kotlin library and use it from a C program. Start by creating a library file in Kotlin and save it as `hello.kt`: ``` package example object Object { val field = "A" } class Clazz { fun memberFunction(p: Int): ULong = 42UL } fun forIntegers(b: Byte, s: Short, i: UInt, l: Long) { } fun forFloats(f: Float, d: Double) { } fun strings(str: String) : String? { return "That is '$str' from C" } val globalString = "A global String" ``` While it is possible to use the command line, either directly or by combining it with a script file (such as `.sh` or `.bat` file), this approach doesn't scale well for big projects that have hundreds of files and libraries. It is then better to use the Kotlin/Native compiler with a build system, as it helps to download and cache the Kotlin/Native compiler binaries and libraries with transitive dependencies and run the compiler and tests. Kotlin/Native can use the [Gradle](https://gradle.org) build system through the [kotlin-multiplatform](multiplatform-discover-project#multiplatform-plugin) plugin. We covered the basics of setting up an IDE compatible project with Gradle in the [A Basic Kotlin/Native Application](native-gradle) tutorial. Please check it out if you are looking for detailed first steps and instructions on how to start a new Kotlin/Native project and open it in IntelliJ IDEA. In this tutorial, we'll look at the advanced C interop related usages of Kotlin/Native and [multiplatform](multiplatform-discover-project#multiplatform-plugin) builds with Gradle. First, create a project folder. All the paths in this tutorial will be relative to this folder. Sometimes the missing directories will have to be created before any new files can be added. Use the following `build.gradle(.kts)` Gradle build file: ``` plugins { kotlin("multiplatform") version "1.8.0" } repositories { mavenCentral() } kotlin { linuxX64("native") { // on Linux // macosX64("native") { // on x86_64 macOS // macosArm64("native") { // on Apple Silicon macOS // mingwX64("native") { // on Windows binaries { sharedLib { baseName = "native" // on Linux and macOS // baseName = "libnative" // on Windows } } } } tasks.wrapper { gradleVersion = "7.3" distributionType = Wrapper.DistributionType.ALL } ``` ``` plugins { id 'org.jetbrains.kotlin.multiplatform' version '1.8.0' } repositories { mavenCentral() } kotlin { linuxX64("native") { // on Linux // macosX64("native") { // on x86_64 macOS // macosArm64("native") { // on Apple Silicon macOS // mingwX64("native") { // on Windows binaries { sharedLib { baseName = "native" // on Linux and macOS // baseName = "libnative" // on Windows } } } } wrapper { gradleVersion = "7.3" distributionType = "ALL" } ``` Move the sources file into the `src/nativeMain/kotlin` folder under the project. This is the default path, for where sources are located, when the [kotlin-multiplatform](multiplatform-discover-project#multiplatform-plugin) plugin is used. Use the following block to instruct and configure the project to generate a dynamic or shared library: ``` binaries { sharedLib { baseName = "native" // on Linux and macOS // baseName = "libnative" // on Windows } } ``` The `libnative` is used as the library name, the generated header file name prefix. It is also prefixes all declarations in the header file. Now you can [open the project in IntelliJ IDEA](native-get-started) and to see how to fix the example project. While doing this, we'll examine how C functions are mapped into Kotlin/Native declarations. Run the `linkNative` Gradle task to build the library in the IDE or by calling the following console command: ``` ./gradlew linkNative ``` The build generates the following files under the `build/bin/native/debugShared` folder, depending on the host OS: * macOS: `libnative_api.h` and `libnative.dylib` * Linux: `libnative_api.h` and `libnative.so` * Windows: `libnative_api.h`, `libnative_symbols.def` and `libnative.dll` The same rules are used by the Kotlin/Native compiler to generate the `.h` file for all platforms. Let's check out the C API of our Kotlin library. Generated headers file ---------------------- In the `libnative_api.h`, you'll find the following code. Let's discuss the code in parts to make it easier to understand. The very first part contains the standard C/C++ header and footer: ``` #ifndef KONAN_DEMO_H #define KONAN_DEMO_H #ifdef __cplusplus extern "C" { #endif /// THE REST OF THE GENERATED CODE GOES HERE #ifdef __cplusplus } /* extern "C" */ #endif #endif /* KONAN_DEMO_H */ ``` After the rituals in the `libnative_api.h`, there is a block with the common type definitions: ``` #ifdef __cplusplus typedef bool libnative_KBoolean; #else typedef _Bool libnative_KBoolean; #endif typedef unsigned short libnative_KChar; typedef signed char libnative_KByte; typedef short libnative_KShort; typedef int libnative_KInt; typedef long long libnative_KLong; typedef unsigned char libnative_KUByte; typedef unsigned short libnative_KUShort; typedef unsigned int libnative_KUInt; typedef unsigned long long libnative_KULong; typedef float libnative_KFloat; typedef double libnative_KDouble; typedef void* libnative_KNativePtr; ``` Kotlin uses the `libnative_` prefix for all declarations in the created `libnative_api.h` file. Let's present the mapping of the types in a more readable way: | Kotlin Define | C Type | | --- | --- | | `libnative_KBoolean` | `bool` or `_Bool` | | `libnative_KChar` | `unsigned short` | | `libnative_KByte` | `signed char` | | `libnative_KShort` | `short` | | `libnative_KInt` | `int` | | `libnative_KLong` | `long long` | | `libnative_KUByte` | `unsigned char` | | `libnative_KUShort` | `unsigned short` | | `libnative_KUInt` | `unsigned int` | | `libnative_KULong` | `unsigned long long` | | `libnative_KFloat` | `float` | | `libnative_KDouble` | `double` | | `libnative_KNativePtr` | `void*` | The definitions part shows how Kotlin primitive types map into C primitive types. The reverse mapping is described in the [Mapping primitive data types from C](mapping-primitive-data-types-from-c) tutorial. The next part of the `libnative_api.h` file contains definitions of the types that are used in the library: ``` struct libnative_KType; typedef struct libnative_KType libnative_KType; typedef struct { libnative_KNativePtr pinned; } libnative_kref_example_Object; typedef struct { libnative_KNativePtr pinned; } libnative_kref_example_Clazz; ``` The `typedef struct { .. } TYPE_NAME` syntax is used in C language to declare a structure. [This thread](https://stackoverflow.com/questions/1675351/typedef-struct-vs-struct-definitions) on Stackoverflow provides more explanations of that pattern. As you can see from these definitions, the Kotlin object `Object` is mapped into `libnative_kref_example_Object`, and `Clazz` is mapped into `libnative_kref_example_Clazz`. Both structs contain nothing but the `pinned` field with a pointer, the field type `libnative_KNativePtr` is defined as `void*` above. There is no namespaces support in C, so the Kotlin/Native compiler generates long names to avoid any possible clashes with other symbols in the existing native project. A significant part of the definitions goes in the `libnative_api.h` file. It includes the definition of our Kotlin/Native library world: ``` typedef struct { /* Service functions. */ void (*DisposeStablePointer)(libnative_KNativePtr ptr); void (*DisposeString)(const char* string); libnative_KBoolean (*IsInstance)(libnative_KNativePtr ref, const libnative_KType* type); /* User functions. */ struct { struct { struct { void (*forIntegers)(libnative_KByte b, libnative_KShort s, libnative_KUInt i, libnative_KLong l); void (*forFloats)(libnative_KFloat f, libnative_KDouble d); const char* (*strings)(const char* str); const char* (*get_globalString)(); struct { libnative_KType* (*_type)(void); libnative_kref_example_Object (*_instance)(); const char* (*get_field)(libnative_kref_example_Object thiz); } Object; struct { libnative_KType* (*_type)(void); libnative_kref_example_Clazz (*Clazz)(); libnative_KULong (*memberFunction)(libnative_kref_example_Clazz thiz, libnative_KInt p); } Clazz; } example; } root; } kotlin; } libnative_ExportedSymbols; ``` The code uses anonymous structure declarations. The code `struct { .. } foo` declares a field in the outer struct of that anonymous structure type, the type with no name. C does not support objects either. People use function pointers to mimic object semantics. A function pointer is declared as follows `RETURN_TYPE (* FIELD_NAME)(PARAMETERS)`. It is tricky to read, but we should be able to see function pointer fields in the structures above. ### Runtime functions The code reads as follows. You have the `libnative_ExportedSymbols` structure, which defines all the functions that Kotlin/Native and our library provides us. It uses nested anonymous structures heavily to mimic packages. The `libnative_` prefix comes from the library name. The `libnative_ExportedSymbols` structure contains several helper functions: ``` void (*DisposeStablePointer)(libnative_KNativePtr ptr); void (*DisposeString)(const char* string); libnative_KBoolean (*IsInstance)(libnative_KNativePtr ref, const libnative_KType* type); ``` These functions deal with Kotlin/Native objects. Call the `DisposeStablePointer` to release a Kotlin object and `DisposeString` to release a Kotlin String, which has the `char*` type in C. It is possible to use the `IsInstance` function to check if a Kotlin type or a `libnative_KNativePtr` is an instance of another type. The actual set of operations generated depends on the actual usages. Kotlin/Native has garbage collection, but it does not help us deal with Kotlin objects from the C language. Kotlin/Native has interop with Objective-C and Swift and integrates with their reference counters. The [Objective-C Interop](native-objc-interop) documentation article contains more details on it. Also, there is the tutorial [Kotlin/Native as an Apple Framework](apple-framework). ### Your library functions Let's take a look at the `kotlin.root.example` field, it mimics the package structure of our Kotlin code with a `kotlin.root.` prefix. There is a `kotlin.root.example.Clazz` field that represents the `Clazz` from Kotlin. The `Clazz#memberFunction` is accessible with the `memberFunction` field. The only difference is that the `memberFunction` accepts a `this` reference as the first parameter. The C language does not support objects, and this is the reason to pass a `this` pointer explicitly. There is a constructor in the `Clazz` field (aka `kotlin.root.example.Clazz.Clazz`), which is the constructor function to create an instance of the `Clazz`. Kotlin `object Object` is accessible as `kotlin.root.example.Object`. There is the `_instance` function to get the only instance of the object. Properties are translated into functions. The `get_` and `set_` prefix is used to name the getter and the setter functions respectively. For example, the read-only property `globalString` from Kotlin is turned into a `get_globalString` function in C. Global functions `forInts`, `forFloats`, or `strings` are turned into the functions pointers in the `kotlin.root.example` anonymous struct. ### Entry point You can see how the API is created. To start with, you need to initialize the `libnative_ExportedSymbols` structure. Let's take a look at the latest part of the `libnative_api.h` for this: ``` extern libnative_ExportedSymbols* libnative_symbols(void); ``` The function `libnative_symbols` allows you to open the way from the native code to the Kotlin/Native library. This is the entry point you'll use. The library name is used as a prefix for the function name. Use generated headers from C ---------------------------- The usage from C is straightforward and uncomplicated. Create a `main.c` file with the following code: ``` #include "libnative_api.h" #include "stdio.h" int main(int argc, char** argv) { //obtain reference for calling Kotlin/Native functions libnative_ExportedSymbols* lib = libnative_symbols(); lib->kotlin.root.example.forIntegers(1, 2, 3, 4); lib->kotlin.root.example.forFloats(1.0f, 2.0); //use C and Kotlin/Native strings const char* str = "Hello from Native!"; const char* response = lib->kotlin.root.example.strings(str); printf("in: %s\nout:%s\n", str, response); lib->DisposeString(response); //create Kotlin object instance libnative_kref_example_Clazz newInstance = lib->kotlin.root.example.Clazz.Clazz(); long x = lib->kotlin.root.example.Clazz.memberFunction(newInstance, 42); lib->DisposeStablePointer(newInstance.pinned); printf("DemoClazz returned %ld\n", x); return 0; } ``` Compile and run the example on Linux and macOS ---------------------------------------------- On macOS 10.13 with Xcode, compile the C code and link it with the dynamic library with the following command: ``` clang main.c libnative.dylib ``` On Linux call a similar command: ``` gcc main.c libnative.so ``` The compiler generates an executable called `a.out`. Run it to see in action the Kotlin code being executed from C library. On Linux, you'll need to include `.` into the `LD_LIBRARY_PATH` to let the application know to load the `libnative.so` library from the current folder. Compile and run the example on Windows -------------------------------------- To start with, you'll need a Microsoft Visual C++ compiler installed that supports a x64\_64 target. The easiest way to do this is to have a version of Microsoft Visual Studio installed on a Windows machine. In this example, you'll be using the `x64 Native Tools Command Prompt <VERSION>` console. You'll see the shortcut to open the console in the start menu. It comes with a Microsoft Visual Studio package. On Windows, Dynamic libraries are included either via a generated static library wrapper or with manual code, which deals with the [LoadLibrary](https://docs.microsoft.com/en-gb/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya) or similar Win32API functions. Follow the first option and generate the static wrapper library for the `libnative.dll` as described below. Call `lib.exe` from the toolchain to generate the static library wrapper `libnative.lib` that automates the DLL usage from the code: ``` lib /def:libnative_symbols.def /out:libnative.lib ``` Now you are ready to compile our `main.c` into an executable. Include the generated `libnative.lib` into the build command and start: ``` cl.exe main.c libnative.lib ``` The command produces the `main.exe` file, which you can run. Next steps ---------- Dynamic libraries are the main way to use Kotlin code from existing programs. You can use them to share your code with many platforms or languages, including JVM, Python, iOS, Android, and others. Kotlin/Native also has tight integration with Objective-C and Swift. It is covered in the [Kotlin/Native as an Apple Framework](apple-framework) tutorial. Last modified: 10 January 2023 [Platform libraries](native-platform-libs) [Kotlin/Native memory management](native-memory-manager) kotlin Kotlin/Native libraries Kotlin/Native libraries ======================= Kotlin compiler specifics ------------------------- To produce a library with the Kotlin/Native compiler use the `-produce library` or `-p library` flag. For example: ``` $ kotlinc-native foo.kt -p library -o bar ``` This command will produce a `bar.klib` with the compiled contents of `foo.kt`. To link to a library use the `-library <name>` or `-l <name>` flag. For example: ``` $ kotlinc-native qux.kt -l bar ``` This command will produce a `program.kexe` out of `qux.kt` and `bar.klib` cinterop tool specifics ----------------------- The **cinterop** tool produces `.klib` wrappers for native libraries as its main output. For example, using the simple `libgit2.def` native library definition file provided in your Kotlin/Native distribution ``` $ cinterop -def samples/gitchurn/src/nativeInterop/cinterop/libgit2.def -compiler-option -I/usr/local/include -o libgit2 ``` we will obtain `libgit2.klib`. See more details in [C Interop](native-c-interop). klib utility ------------ The **klib** library management utility allows you to inspect and install the libraries. The following commands are available: * `content` – list library contents: ``` $ klib contents <name> ``` * `info` – inspect the bookkeeping details of the library ``` $ klib info <name> ``` * `install` – install the library to the default location use ``` $ klib install <name> ``` * `remove` – remove the library from the default repository use ``` $ klib remove <name> ``` All of the above commands accept an additional `-repository <directory>` argument for specifying a repository different to the default one. ``` $ klib <command> <name> -repository <directory> ``` Several examples ---------------- First let's create a library. Place the tiny library source code into `kotlinizer.kt`: ``` package kotlinizer val String.kotlinized get() = "Kotlin $this" ``` ``` $ kotlinc-native kotlinizer.kt -p library -o kotlinizer ``` The library has been created in the current directory: ``` $ ls kotlinizer.klib kotlinizer.klib ``` Now let's check out the contents of the library: ``` $ klib contents kotlinizer ``` You can install `kotlinizer` to the default repository: ``` $ klib install kotlinizer ``` Remove any traces of it from the current directory: ``` $ rm kotlinizer.klib ``` Create a very short program and place it into a `use.kt`: ``` import kotlinizer.* fun main(args: Array<String>) { println("Hello, ${"world".kotlinized}!") } ``` Now compile the program linking with the library you have just created: ``` $ kotlinc-native use.kt -l kotlinizer -o kohello ``` And run the program: ``` $ ./kohello.kexe Hello, Kotlin world! ``` Have fun! Advanced topics --------------- ### Library search sequence When given a `-library foo` flag, the compiler searches the `foo` library in the following order: * Current compilation directory or an absolute path. * All repositories specified with `-repo` flag. * Libraries installed in the default repository (For now the default is `~/.konan`, however it could be changed by setting **KONAN\_DATA\_DIR** environment variable). * Libraries installed in `$installation/klib` directory. ### Library format Kotlin/Native libraries are zip files containing a predefined directory structure, with the following layout: `foo.klib` when unpacked as `foo/` gives us: ``` - foo/ - $component_name/ - ir/ - Serialized Kotlin IR. - targets/ - $platform/ - kotlin/ - Kotlin compiled to LLVM bitcode. - native/ - Bitcode files of additional native objects. - $another_platform/ - There can be several platform specific kotlin and native pairs. - linkdata/ - A set of ProtoBuf files with serialized linkage metadata. - resources/ - General resources such as images. (Not used yet). - manifest - A file in the java property format describing the library. ``` An example layout can be found in `klib/stdlib` directory of your installation. ### Using relative paths in klibs A serialized IR representation of source files is [a part of](#library-format) a `klib` library. It includes paths of files for generating proper debug information. By default, stored paths are absolute. With the `-Xklib-relative-path-base` compiler option, you can change the format and use only relative path in the artifact. To make it work, pass one or multiple base paths of source files as an argument: ``` tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask::class).configureEach { // $base is a base path of source files compilerOptions.freeCompilerArgs.add("-Xklib-relative-path-base=$base") } ``` ``` tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask).configureEach { compilerOptions { // $base is a base path of source files freeCompilerArgs.add("-Xklib-relative-path-base=$base") } } ``` Last modified: 10 January 2023 [CocoaPods Gradle plugin DSL reference](native-cocoapods-dsl-reference) [Platform libraries](native-platform-libs)
programming_docs
kotlin Select expression (experimental) Select expression (experimental) ================================ Select expression makes it possible to await multiple suspending functions simultaneously and *select* the first one that becomes available. Selecting from channels ----------------------- Let us have two producers of strings: `fizz` and `buzz`. The `fizz` produces "Fizz" string every 300 ms: ``` fun CoroutineScope.fizz() = produce<String> { while (true) { // sends "Fizz" every 300 ms delay(300) send("Fizz") } } ``` And the `buzz` produces "Buzz!" string every 500 ms: ``` fun CoroutineScope.buzz() = produce<String> { while (true) { // sends "Buzz!" every 500 ms delay(500) send("Buzz!") } } ``` Using [receive](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/receive.html) suspending function we can receive *either* from one channel or the other. But [select](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.selects/select.html) expression allows us to receive from *both* simultaneously using its [onReceive](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive.html) clauses: ``` suspend fun selectFizzBuzz(fizz: ReceiveChannel<String>, buzz: ReceiveChannel<String>) { select<Unit> { // <Unit> means that this select expression does not produce any result fizz.onReceive { value -> // this is the first select clause println("fizz -> '$value'") } buzz.onReceive { value -> // this is the second select clause println("buzz -> '$value'") } } } ``` Let us run it all seven times: ``` import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.selects.* fun CoroutineScope.fizz() = produce<String> { while (true) { // sends "Fizz" every 300 ms delay(300) send("Fizz") } } fun CoroutineScope.buzz() = produce<String> { while (true) { // sends "Buzz!" every 500 ms delay(500) send("Buzz!") } } suspend fun selectFizzBuzz(fizz: ReceiveChannel<String>, buzz: ReceiveChannel<String>) { select<Unit> { // <Unit> means that this select expression does not produce any result fizz.onReceive { value -> // this is the first select clause println("fizz -> '$value'") } buzz.onReceive { value -> // this is the second select clause println("buzz -> '$value'") } } } fun main() = runBlocking<Unit> { //sampleStart val fizz = fizz() val buzz = buzz() repeat(7) { selectFizzBuzz(fizz, buzz) } coroutineContext.cancelChildren() // cancel fizz & buzz coroutines //sampleEnd } ``` The result of this code is: ``` fizz -> 'Fizz' buzz -> 'Buzz!' fizz -> 'Fizz' fizz -> 'Fizz' buzz -> 'Buzz!' fizz -> 'Fizz' buzz -> 'Buzz!' ``` Selecting on close ------------------ The [onReceive](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive.html) clause in `select` fails when the channel is closed causing the corresponding `select` to throw an exception. We can use [onReceiveCatching](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive-catching.html) clause to perform a specific action when the channel is closed. The following example also shows that `select` is an expression that returns the result of its selected clause: ``` suspend fun selectAorB(a: ReceiveChannel<String>, b: ReceiveChannel<String>): String = select<String> { a.onReceiveCatching { it -> val value = it.getOrNull() if (value != null) { "a -> '$value'" } else { "Channel 'a' is closed" } } b.onReceiveCatching { it -> val value = it.getOrNull() if (value != null) { "b -> '$value'" } else { "Channel 'b' is closed" } } } ``` Let's use it with channel `a` that produces "Hello" string four times and channel `b` that produces "World" four times: ``` import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.selects.* suspend fun selectAorB(a: ReceiveChannel<String>, b: ReceiveChannel<String>): String = select<String> { a.onReceiveCatching { it -> val value = it.getOrNull() if (value != null) { "a -> '$value'" } else { "Channel 'a' is closed" } } b.onReceiveCatching { it -> val value = it.getOrNull() if (value != null) { "b -> '$value'" } else { "Channel 'b' is closed" } } } fun main() = runBlocking<Unit> { //sampleStart val a = produce<String> { repeat(4) { send("Hello $it") } } val b = produce<String> { repeat(4) { send("World $it") } } repeat(8) { // print first eight results println(selectAorB(a, b)) } coroutineContext.cancelChildren() //sampleEnd } ``` The result of this code is quite interesting, so we'll analyze it in more detail: ``` a -> 'Hello 0' a -> 'Hello 1' b -> 'World 0' a -> 'Hello 2' a -> 'Hello 3' b -> 'World 1' Channel 'a' is closed Channel 'a' is closed ``` There are a couple of observations to make out of it. First of all, `select` is *biased* to the first clause. When several clauses are selectable at the same time, the first one among them gets selected. Here, both channels are constantly producing strings, so `a` channel, being the first clause in select, wins. However, because we are using unbuffered channel, the `a` gets suspended from time to time on its [send](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/send.html) invocation and gives a chance for `b` to send, too. The second observation, is that [onReceiveCatching](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive-catching.html) gets immediately selected when the channel is already closed. Selecting to send ----------------- Select expression has [onSend](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/on-send.html) clause that can be used for a great good in combination with a biased nature of selection. Let us write an example of a producer of integers that sends its values to a `side` channel when the consumers on its primary channel cannot keep up with it: ``` fun CoroutineScope.produceNumbers(side: SendChannel<Int>) = produce<Int> { for (num in 1..10) { // produce 10 numbers from 1 to 10 delay(100) // every 100 ms select<Unit> { onSend(num) {} // Send to the primary channel side.onSend(num) {} // or to the side channel } } } ``` Consumer is going to be quite slow, taking 250 ms to process each number: ``` import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.selects.* fun CoroutineScope.produceNumbers(side: SendChannel<Int>) = produce<Int> { for (num in 1..10) { // produce 10 numbers from 1 to 10 delay(100) // every 100 ms select<Unit> { onSend(num) {} // Send to the primary channel side.onSend(num) {} // or to the side channel } } } fun main() = runBlocking<Unit> { //sampleStart val side = Channel<Int>() // allocate side channel launch { // this is a very fast consumer for the side channel side.consumeEach { println("Side channel has $it") } } produceNumbers(side).consumeEach { println("Consuming $it") delay(250) // let us digest the consumed number properly, do not hurry } println("Done consuming") coroutineContext.cancelChildren() //sampleEnd } ``` So let us see what happens: ``` Consuming 1 Side channel has 2 Side channel has 3 Consuming 4 Side channel has 5 Side channel has 6 Consuming 7 Side channel has 8 Side channel has 9 Consuming 10 Done consuming ``` Selecting deferred values ------------------------- Deferred values can be selected using [onAwait](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/on-await.html) clause. Let us start with an async function that returns a deferred string value after a random delay: ``` fun CoroutineScope.asyncString(time: Int) = async { delay(time.toLong()) "Waited for $time ms" } ``` Let us start a dozen of them with a random delay. ``` fun CoroutineScope.asyncStringsList(): List<Deferred<String>> { val random = Random(3) return List(12) { asyncString(random.nextInt(1000)) } } ``` Now the main function awaits for the first of them to complete and counts the number of deferred values that are still active. Note that we've used here the fact that `select` expression is a Kotlin DSL, so we can provide clauses for it using an arbitrary code. In this case we iterate over a list of deferred values to provide `onAwait` clause for each deferred value. ``` import kotlinx.coroutines.* import kotlinx.coroutines.selects.* import java.util.* fun CoroutineScope.asyncString(time: Int) = async { delay(time.toLong()) "Waited for $time ms" } fun CoroutineScope.asyncStringsList(): List<Deferred<String>> { val random = Random(3) return List(12) { asyncString(random.nextInt(1000)) } } fun main() = runBlocking<Unit> { //sampleStart val list = asyncStringsList() val result = select<String> { list.withIndex().forEach { (index, deferred) -> deferred.onAwait { answer -> "Deferred $index produced answer '$answer'" } } } println(result) val countActive = list.count { it.isActive } println("$countActive coroutines are still active") //sampleEnd } ``` The output is: ``` Deferred 4 produced answer 'Waited for 128 ms' 11 coroutines are still active ``` Switch over a channel of deferred values ---------------------------------------- Let us write a channel producer function that consumes a channel of deferred string values, waits for each received deferred value, but only until the next deferred value comes over or the channel is closed. This example puts together [onReceiveCatching](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-receive-channel/on-receive-catching.html) and [onAwait](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/on-await.html) clauses in the same `select`: ``` fun CoroutineScope.switchMapDeferreds(input: ReceiveChannel<Deferred<String>>) = produce<String> { var current = input.receive() // start with first received deferred value while (isActive) { // loop while not cancelled/closed val next = select<Deferred<String>?> { // return next deferred value from this select or null input.onReceiveCatching { update -> update.getOrNull() } current.onAwait { value -> send(value) // send value that current deferred has produced input.receiveCatching().getOrNull() // and use the next deferred from the input channel } } if (next == null) { println("Channel was closed") break // out of loop } else { current = next } } } ``` To test it, we'll use a simple async function that resolves to a specified string after a specified time: ``` fun CoroutineScope.asyncString(str: String, time: Long) = async { delay(time) str } ``` The main function just launches a coroutine to print results of `switchMapDeferreds` and sends some test data to it: ``` import kotlinx.coroutines.* import kotlinx.coroutines.channels.* import kotlinx.coroutines.selects.* fun CoroutineScope.switchMapDeferreds(input: ReceiveChannel<Deferred<String>>) = produce<String> { var current = input.receive() // start with first received deferred value while (isActive) { // loop while not cancelled/closed val next = select<Deferred<String>?> { // return next deferred value from this select or null input.onReceiveCatching { update -> update.getOrNull() } current.onAwait { value -> send(value) // send value that current deferred has produced input.receiveCatching().getOrNull() // and use the next deferred from the input channel } } if (next == null) { println("Channel was closed") break // out of loop } else { current = next } } } fun CoroutineScope.asyncString(str: String, time: Long) = async { delay(time) str } fun main() = runBlocking<Unit> { //sampleStart val chan = Channel<Deferred<String>>() // the channel for test launch { // launch printing coroutine for (s in switchMapDeferreds(chan)) println(s) // print each received string } chan.send(asyncString("BEGIN", 100)) delay(200) // enough time for "BEGIN" to be produced chan.send(asyncString("Slow", 500)) delay(100) // not enough time to produce slow chan.send(asyncString("Replace", 100)) delay(500) // give it time before the last one chan.send(asyncString("END", 500)) delay(1000) // give it time to process chan.close() // close the channel ... delay(500) // and wait some time to let it finish //sampleEnd } ``` The result of this code: ``` BEGIN Replace END Channel was closed ``` Last modified: 10 January 2023 [Shared mutable state and concurrency](shared-mutable-state-and-concurrency) [Debug coroutines using IntelliJ IDEA – tutorial](debug-coroutines-with-idea) kotlin Contribution Contribution ============ Kotlin is an open-source project under the [Apache 2.0 License](https://github.com/JetBrains/kotlin/blob/master/license/LICENSE.txt). The source code, tooling, documentation, and even this web site are maintained on [GitHub](https://github.com/jetbrains/kotlin). While Kotlin is mostly developed by JetBrains, there are hundreds of external contributors to the Kotlin project and we are always on the lookout for more people to help us. Participate in Early Access Preview ----------------------------------- You can help us improve Kotlin by [participating in Kotlin Early Access Preview (EAP)](eap) and providing us with your valuable feedback. For every release, Kotlin ships a few preview builds where you can try out the latest features before they go to production. You can report any bugs you find to our issue tracker [YouTrack](https://kotl.in/issue) and we will try to fix them before a final release. This way, you can get bug fixes earlier than the standard Kotlin release cycle. Contribute to the compiler and standard library ----------------------------------------------- If you want to contribute to the Kotlin compiler and standard library, go to [JetBrains/Kotlin GitHub](https://github.com/jetbrains/kotlin), check out the latest Kotlin version, and follow [the instructions on how to contribute](https://github.com/JetBrains/kotlin/blob/master/docs/contributing.md). You can help us by completing [open tasks](https://youtrack.jetbrains.com/issues/KT?q=tag:%20%7BUp%20For%20Grabs%7D%20and%20State:%20Open). Please keep an open line of communication with us because we may have questions and comments on your changes. Otherwise, we won't be able to incorporate your contributions. Contribute to the Kotlin IDE plugin ----------------------------------- Kotlin IDE plugin is a part of the [IntelliJ IDEA repository](https://github.com/JetBrains/intellij-community/tree/master/plugins/kotlin). To contribute to the Kotlin IDE plugin, clone the [IntelliJ IDEA repository](https://github.com/JetBrains/intellij-community/) and follow the [instructions on how to contribute](https://github.com/JetBrains/intellij-community/blob/master/plugins/kotlin/CONTRIBUTING.md). Contribute to other Kotlin libraries and tools ---------------------------------------------- Besides the standard library that provides core capabilities, Kotlin has a number of additional (kotlinx) libraries that extend its functionality. Each kotlinx library is developed in a separate repository, has its own versioning and release cycle. If you want to contribute to a kotlinx library (such as [kotlinx.coroutines](https://github.com/Kotlin/kotlinx.coroutines) or [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization)) and tools, go to [Kotlin GitHub](https://github.com/Kotlin), choose the repository you are interested in and clone it. Follow the contribution process described for each library and tool, such as [kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/CONTRIBUTING.md), [ktor](https://github.com/ktorio/ktor/blob/master/CONTRIBUTING.md) and others. If you have a library that could be useful to other Kotlin developers, let us know via [[email protected]](mailto:[email protected]). Contribute to the documentation ------------------------------- If you've found an issue in the Kotlin documentation, feel free to check out [the documentation source code on GitHub](https://github.com/JetBrains/kotlin-web-site/tree/master/docs/topics) and send us a pull request. Follow [these guidelines on style and formatting](https://docs.google.com/document/d/1mUuxK4xwzs3jtDGoJ5_zwYLaSEl13g_SuhODdFuh2Dc/edit?usp=sharing). Please keep an open line of communication with us because we may have questions and comments on your changes. Otherwise, we won't be able to incorporate your contributions. Create tutorials or videos -------------------------- If you've created tutorials or videos for Kotlin, please share them with us via [[email protected]](mailto:[email protected]). Translate documentation to other languages ------------------------------------------ You are welcome to translate the Kotlin documentation into your own language and publish the translation on your website. However, we won't be able to host your translation in the main repository and publish it on [kotlinlang.org](https://kotlinlang.org/). This site is the official documentation for the language, and we ensure that all the information here is correct and up to date. Unfortunately, we won't be able to review documentation in other languages. Hold events and presentations ----------------------------- If you've given or just plan to give presentations or hold events on Kotlin, please fill out [the form](https://surveys.jetbrains.com/s3/Submit-a-Kotlin-Talk). We'll feature them on [the event list](https://kotlinlang.org/docs/events.html). Last modified: 10 January 2023 [Kotlin documentation as PDF](kotlin-pdf) [KUG guidelines](kug-guidelines) kotlin Using kapt Using kapt ========== Annotation processors (see [JSR 269](https://jcp.org/en/jsr/detail?id=269)) are supported in Kotlin with the *kapt* compiler plugin. In a nutshell, you can use libraries such as [Dagger](https://google.github.io/dagger/) or [Data Binding](https://developer.android.com/topic/libraries/data-binding/index.html) in your Kotlin projects. Please read below about how to apply the *kapt* plugin to your Gradle/Maven build. Using in Gradle --------------- Follow these steps: 1. Apply the `kotlin-kapt` Gradle plugin: ``` plugins { kotlin("kapt") version "1.8.0" } ``` ``` plugins { id "org.jetbrains.kotlin.kapt" version "1.8.0" } ``` 2. Add the respective dependencies using the `kapt` configuration in your `dependencies` block: ``` dependencies { kapt("groupId:artifactId:version") } ``` ``` dependencies { kapt 'groupId:artifactId:version' } ``` 3. If you previously used the [Android support](https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#annotationProcessor_config) for annotation processors, replace usages of the `annotationProcessor` configuration with `kapt`. If your project contains Java classes, `kapt` will also take care of them. If you use annotation processors for your `androidTest` or `test` sources, the respective `kapt` configurations are named `kaptAndroidTest` and `kaptTest`. Note that `kaptAndroidTest` and `kaptTest` extends `kapt`, so you can just provide the `kapt` dependency and it will be available both for production sources and tests. 4. To use the newest Kotlin features with kapt, for example, [repeatable annotations](annotations#repeatable-annotations), enable the support for the [IR backend](https://blog.jetbrains.com/kotlin/2021/02/the-jvm-backend-is-in-beta-let-s-make-it-stable-together/) with the following option in your `gradle.properties`: ``` kapt.use.jvm.ir=true ``` Annotation processor arguments ------------------------------ Use `arguments {}` block to pass arguments to annotation processors: ``` kapt { arguments { arg("key", "value") } } ``` Gradle build cache support -------------------------- The kapt annotation processing tasks are [cached in Gradle](https://guides.gradle.org/using-build-cache/) by default. However, annotation processors run arbitrary code that may not necessarily transform the task inputs into the outputs, might access and modify the files that are not tracked by Gradle etc. If the annotation processors used in the build cannot be properly cached, it is possible to disable caching for kapt entirely by adding the following lines to the build script, in order to avoid false-positive cache hits for the kapt tasks: ``` kapt { useBuildCache = false } ``` Improving the speed of builds that use kapt ------------------------------------------- ### Running kapt tasks in parallel To improve the speed of builds that use kapt, you can enable the [Gradle Worker API](https://guides.gradle.org/using-the-worker-api/) for kapt tasks. Using the Worker API lets Gradle run independent annotation processing tasks from a single project in parallel, which in some cases significantly decreases the execution time. When you use the [custom JDK home](gradle-configure-project#gradle-java-toolchains-support) feature in the Kotlin Gradle plugin, kapt task workers use only [process isolation mode](https://docs.gradle.org/current/userguide/worker_api.html#changing_the_isolation_mode). Note that the `kapt.workers.isolation` property is ignored. If you want to provide additional JVM arguments for a kapt worker process, use the input `kaptProcessJvmArgs` of the `KaptWithoutKotlincTask`: ``` tasks.withType<org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask>() .configureEach { kaptProcessJvmArgs.add("-Xmx512m") } ``` ``` tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask.class) .configureEach { kaptProcessJvmArgs.add('-Xmx512m') } ``` ### Caching for annotation processors' classloaders Caching for annotation processors' classloaders helps kapt perform faster if you run many Gradle tasks consecutively. To enable this feature, use the following properties in your `gradle.properties` file: ``` # positive value will enable caching # use the same value as the number of modules that use kapt kapt.classloaders.cache.size=5 # disable for caching to work kapt.include.compile.classpath=false ``` If you run into any problems with caching for annotation processors, disable caching for them: ``` # specify annotation processors' full names to disable caching for them kapt.classloaders.cache.disableForProcessors=[annotation processors full names] ``` ### Measuring performance of annotation processors Get a performance statistics on the annotation processors execution using the `-Kapt-show-processor-timings` plugin option. An example output: ``` Kapt Annotation Processing performance report: com.example.processor.TestingProcessor: total: 133 ms, init: 36 ms, 2 round(s): 97 ms, 0 ms com.example.processor.AnotherProcessor: total: 100 ms, init: 6 ms, 1 round(s): 93 ms ``` You can dump this report into a file with the plugin option [`-Kapt-dump-processor-timings` (`org.jetbrains.kotlin.kapt3:dumpProcessorTimings`)](https://github.com/JetBrains/kotlin/pull/4280). The following command will run kapt and dump the statistics to the `ap-perf-report.file` file: ``` kotlinc -cp $MY_CLASSPATH \ -Xplugin=kotlin-annotation-processing-SNAPSHOT.jar -P \ plugin:org.jetbrains.kotlin.kapt3:aptMode=stubsAndApt,\ plugin:org.jetbrains.kotlin.kapt3:apclasspath=processor/build/libs/processor.jar,\ plugin:org.jetbrains.kotlin.kapt3:dumpProcessorTimings=ap-perf-report.file \ -Xplugin=$JAVA_HOME/lib/tools.jar \ -d cli-tests/out \ -no-jdk -no-reflect -no-stdlib -verbose \ sample/src/main/ ``` ### Measuring the number of files generated with annotation processors The `kotlin-kapt` Gradle plugin can report statistics on the number of generated files for each annotation processor. This is useful to track if there are unused annotation processors as a part of the build. You can use the generated report to find modules that trigger unnecessary annotation processors and update the modules to prevent that. Enable the statistics in two steps: * Set the `showProcessorStats` flag to `true` in your `build.gradle.kts`: ``` kapt { showProcessorStats = true } ``` * Set the `kapt.verbose` Gradle property to `true` in your `gradle.properties`: ``` kapt.verbose=true ``` The statistics will appear in the logs with the `info` level. You'll see the `Annotation processor stats:` line followed by statistics on the execution time of each annotation processor. After these lines, there will be the `Generated files report:` line followed by statistics on the number of generated files for each annotation processor. For example: ``` [INFO] Annotation processor stats: [INFO] org.mapstruct.ap.MappingProcessor: total: 290 ms, init: 1 ms, 3 round(s): 289 ms, 0 ms, 0 ms [INFO] Generated files report: [INFO] org.mapstruct.ap.MappingProcessor: total sources: 2, sources per round: 2, 0, 0 ``` Compile avoidance for kapt -------------------------- To improve the times of incremental builds with kapt, it can use the Gradle [compile avoidance](https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_compile_avoidance). With compile avoidance enabled, Gradle can skip annotation processing when rebuilding a project. Particularly, annotation processing is skipped when: * The project's source files are unchanged. * The changes in dependencies are [ABI](https://en.wikipedia.org/wiki/Application_binary_interface) compatible. For example, the only changes are in method bodies. However, compile avoidance can't be used for annotation processors discovered in the compile classpath since *any changes* in them require running the annotation processing tasks. To run kapt with compile avoidance: * Add the annotation processor dependencies to the `kapt*` configurations manually as described [above](#using-in-gradle). * Turn off the discovery of annotation processors in the compile classpath by adding this line to your `gradle.properties` file: ``` kapt.include.compile.classpath=false ``` Incremental annotation processing --------------------------------- kapt supports incremental annotation processing that is enabled by default. Currently, annotation processing can be incremental only if all annotation processors being used are incremental. To disable incremental annotation processing, add this line to your `gradle.properties` file: ``` kapt.incremental.apt=false ``` Note that incremental annotation processing requires [incremental compilation](gradle-compilation-and-caches#incremental-compilation) to be enabled as well. Java compiler options --------------------- kapt uses Java compiler to run annotation processors. Here is how you can pass arbitrary options to javac: ``` kapt { javacOptions { // Increase the max count of errors from annotation processors. // Default is 100. option("-Xmaxerrs", 500) } } ``` Non-existent type correction ---------------------------- Some annotation processors (such as `AutoFactory`) rely on precise types in declaration signatures. By default, kapt replaces every unknown type (including types for the generated classes) to `NonExistentClass`, but you can change this behavior. Add the option to the `build.gradle` file to enable error type inferring in stubs: ``` kapt { correctErrorTypes = true } ``` Using in Maven -------------- Add an execution of the `kapt` goal from kotlin-maven-plugin before `compile`: ``` <execution> <id>kapt</id> <goals> <goal>kapt</goal> </goals> <configuration> <sourceDirs> <sourceDir>src/main/kotlin</sourceDir> <sourceDir>src/main/java</sourceDir> </sourceDirs> <annotationProcessorPaths> <!-- Specify your annotation processors here. --> <annotationProcessorPath> <groupId>com.google.dagger</groupId> <artifactId>dagger-compiler</artifactId> <version>2.9</version> </annotationProcessorPath> </annotationProcessorPaths> </configuration> </execution> ``` Please note that kapt is still not supported for IntelliJ IDEA's own build system. Launch the build from the "Maven Projects" toolbar whenever you want to re-run the annotation processing. Using in CLI ------------ kapt compiler plugin is available in the binary distribution of the Kotlin compiler. You can attach the plugin by providing the path to its JAR file using the `Xplugin` kotlinc option: ``` -Xplugin=$KOTLIN_HOME/lib/kotlin-annotation-processing.jar ``` Here is a list of the available options: * `sources` (*required*): An output path for the generated files. * `classes` (*required*): An output path for the generated class files and resources. * `stubs` (*required*): An output path for the stub files. In other words, some temporary directory. * `incrementalData`: An output path for the binary stubs. * `apclasspath` (*repeatable*): A path to the annotation processor JAR. Pass as many `apclasspath` options as many JARs you have. * `apoptions`: A base64-encoded list of the annotation processor options. See [AP/javac options encoding](#ap-javac-options-encoding) for more information. * `javacArguments`: A base64-encoded list of the options passed to javac. See [AP/javac options encoding](#ap-javac-options-encoding) for more information. * `processors`: A comma-specified list of annotation processor qualified class names. If specified, kapt does not try to find annotation processors in `apclasspath`. * `verbose`: Enable verbose output. * `aptMode` (*required*) + `stubs` – only generate stubs needed for annotation processing; + `apt` – only run annotation processing; + `stubsAndApt` – generate stubs and run annotation processing. * `correctErrorTypes`: See [below](#using-in-gradle). Disabled by default. The plugin option format is: `-P plugin:<plugin id>:<key>=<value>`. Options can be repeated. An example: ``` -P plugin:org.jetbrains.kotlin.kapt3:sources=build/kapt/sources -P plugin:org.jetbrains.kotlin.kapt3:classes=build/kapt/classes -P plugin:org.jetbrains.kotlin.kapt3:stubs=build/kapt/stubs -P plugin:org.jetbrains.kotlin.kapt3:apclasspath=lib/ap.jar -P plugin:org.jetbrains.kotlin.kapt3:apclasspath=lib/anotherAp.jar -P plugin:org.jetbrains.kotlin.kapt3:correctErrorTypes=true ``` Generating Kotlin sources ------------------------- kapt can generate Kotlin sources. Just write the generated Kotlin source files to the directory specified by `processingEnv.options["kapt.kotlin.generated"]`, and these files will be compiled together with the main sources. Note that kapt does not support multiple rounds for the generated Kotlin files. AP/Javac options encoding ------------------------- `apoptions` and `javacArguments` CLI options accept an encoded map of options. Here is how you can encode options by yourself: ``` fun encodeList(options: Map<String, String>): String { val os = ByteArrayOutputStream() val oos = ObjectOutputStream(os) oos.writeInt(options.size) for ((key, value) in options.entries) { oos.writeUTF(key) oos.writeUTF(value) } oos.flush() return Base64.getEncoder().encodeToString(os.toByteArray()) } ``` Keeping Java compiler's annotation processors --------------------------------------------- By default, kapt runs all annotation processors and disables annotation processing by javac. However, you may need some of javac's annotation processors working (for example, [Lombok](https://projectlombok.org/)). In the Gradle build file, use the option `keepJavacAnnotationProcessors`: ``` kapt { keepJavacAnnotationProcessors = true } ``` If you use Maven, you need to specify concrete plugin settings. See this [example of settings for the Lombok compiler plugin](lombok#using-with-kapt). Last modified: 10 January 2023 [SAM-with-receiver compiler plugin](sam-with-receiver-plugin) [Lombok compiler plugin](lombok)
programming_docs
kotlin Plus and minus operators Plus and minus operators ======================== In Kotlin, [`plus`](../api/latest/jvm/stdlib/kotlin.collections/plus) (`+`) and [`minus`](../api/latest/jvm/stdlib/kotlin.collections/minus) (`-`) operators are defined for collections. They take a collection as the first operand; the second operand can be either an element or another collection. The return value is a new read-only collection: * The result of `plus` contains the elements from the original collection *and* from the second operand. * The result of `minus` contains the elements of the original collection *except* the elements from the second operand. If it's an element, `minus` removes its *first* occurrence; if it's a collection, *all* occurrences of its elements are removed. ``` fun main() { //sampleStart val numbers = listOf("one", "two", "three", "four") val plusList = numbers + "five" val minusList = numbers - listOf("three", "four") println(plusList) println(minusList) //sampleEnd } ``` For the details on `plus` and `minus` operators for maps, see [Map specific operations](map-operations). The [augmented assignment operators](operator-overloading#augmented-assignments) [`plusAssign`](../api/latest/jvm/stdlib/kotlin.collections/plus-assign) (`+=`) and [`minusAssign`](../api/latest/jvm/stdlib/kotlin.collections/minus-assign) (`-=`) are also defined for collections. However, for read-only collections, they actually use the `plus` or `minus` operators and try to assign the result to the same variable. Thus, they are available only on `var` read-only collections. For mutable collections, they modify the collection if it's a `val`. For more details see [Collection write operations](collection-write). Last modified: 10 January 2023 [Filtering collections](collection-filtering) [Grouping](collection-grouping) kotlin Typesafe HTML DSL Typesafe HTML DSL ================= The [kotlinx.html library](https://www.github.com/kotlin/kotlinx.html) provides the ability to generate DOM elements using statically typed HTML builders (and besides JavaScript, it is even available on the JVM target!) To use the library, include the corresponding repository and dependency to our `build.gradle.kts` file: ``` repositories { // ... jcenter() } dependencies { implementation(kotlin("stdlib-js")) implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.7.1") // ... } ``` Once the dependency is included, you can access the different interfaces provided to generate the DOM. To render a headline, some text, and a link, the following snippet would be sufficient, for example: ``` import kotlinx.browser.* import kotlinx.html.* import kotlinx.html.dom.* fun main() { document.body!!.append.div { h1 { +"Welcome to Kotlin/JS!" } p { +"Fancy joining this year's " a("https://kotlinconf.com/") { +"KotlinConf" } +"?" } } } ``` When running this example in the browser, the DOM will be assembled in a straightforward way. This is easily confirmed by checking the Elements of the website using the developer tools of our browser: ![Rendering a website from kotlinx.html](https://kotlinlang.org/docs/images/rendering-example.png "Rendering a website from kotlinx.html")To learn more about the `kotlinx.html` library, check out the [GitHub Wiki](https://github.com/Kotlin/kotlinx.html/wiki/Getting-started), where you can find more information about how to [create elements](https://github.com/Kotlin/kotlinx.html/wiki/DOM-trees) without adding them to the DOM, [binding to events](https://github.com/Kotlin/kotlinx.html/wiki/Events) like `onClick`, and examples on how to [apply CSS classes](https://github.com/Kotlin/kotlinx.html/wiki/Elements-CSS-classes) to your HTML elements, to name just a few. Last modified: 10 January 2023 [Kotlin/JS reflection](js-reflection) [Generation of external declarations with Dukat](js-external-declarations-with-dukat) kotlin Debugging Kotlin/Native Debugging Kotlin/Native ======================= Currently, the Kotlin/Native compiler produces debug info compatible with the DWARF 2 specification, so modern debugger tools can perform the following operations: * breakpoints * stepping * inspection of type information * variable inspection Produce binaries with debug info with Kotlin/Native compiler ------------------------------------------------------------ To produce binaries with the Kotlin/Native compiler, use the `-g` option on the command line. ``` 0:b-debugger-fixes:minamoto@unit-703(0)# cat - > hello.kt fun main(args: Array<String>) { println("Hello world") println("I need your clothes, your boots and your motocycle") } 0:b-debugger-fixes:minamoto@unit-703(0)# dist/bin/konanc -g hello.kt -o terminator KtFile: hello.kt 0:b-debugger-fixes:minamoto@unit-703(0)# lldb terminator.kexe (lldb) target create "terminator.kexe" Current executable set to 'terminator.kexe' (x86_64). (lldb) b kfun:main(kotlin.Array<kotlin.String>) Breakpoint 1: where = terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) + 4 at hello.kt:2, address = 0x00000001000012e4 (lldb) r Process 28473 launched: '/Users/minamoto/ws/.git-trees/debugger-fixes/terminator.kexe' (x86_64) Process 28473 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x00000001000012e4 terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) at hello.kt:2 1 fun main(args: Array<String>) { -> 2 println("Hello world") 3 println("I need your clothes, your boots and your motocycle") 4 } (lldb) n Hello world Process 28473 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = step over frame #0: 0x00000001000012f0 terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) at hello.kt:3 1 fun main(args: Array<String>) { 2 println("Hello world") -> 3 println("I need your clothes, your boots and your motocycle") 4 } (lldb) ``` Breakpoints ----------- Modern debuggers provide several ways to set a breakpoint, see below for a tool-by-tool breakdown: ### lldb * by name ``` (lldb) b -n kfun:main(kotlin.Array<kotlin.String>) Breakpoint 4: where = terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) + 4 at hello.kt:2, address = 0x00000001000012e4 ``` *`-n` is optional, this flag is applied by default* * by location (filename, line number) ``` (lldb) b -f hello.kt -l 1 Breakpoint 1: where = terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) + 4 at hello.kt:2, address = 0x00000001000012e4 ``` * by address ``` (lldb) b -a 0x00000001000012e4 Breakpoint 2: address = 0x00000001000012e4 ``` * by regex, you might find it useful for debugging generated artifacts, like lambda etc. (where used `#` symbol in name). ``` 3: regex = 'main\(', locations = 1 3.1: where = terminator.kexe`kfun:main(kotlin.Array<kotlin.String>) + 4 at hello.kt:2, address = terminator.kexe[0x00000001000012e4], unresolved, hit count = 0 ``` ### gdb * by regex ``` (gdb) rbreak main( Breakpoint 1 at 0x1000109b4 struct ktype:kotlin.Unit &kfun:main(kotlin.Array<kotlin.String>); ``` * by name **unusable**, because `:` is a separator for the breakpoint by location ``` (gdb) b kfun:main(kotlin.Array<kotlin.String>) No source file named kfun. Make breakpoint pending on future shared library load? (y or [n]) y Breakpoint 1 (kfun:main(kotlin.Array<kotlin.String>)) pending ``` * by location ``` (gdb) b hello.kt:1 Breakpoint 2 at 0x100001704: file /Users/minamoto/ws/.git-trees/hello.kt, line 1. ``` * by address ``` (gdb) b *0x100001704 Note: breakpoint 2 also set at pc 0x100001704. Breakpoint 3 at 0x100001704: file /Users/minamoto/ws/.git-trees/hello.kt, line 2. ``` Stepping -------- Stepping functions works mostly the same way as for C/C++ programs. Variable inspection ------------------- Variable inspections for `var` variables works out of the box for primitive types. For non-primitive types there are custom pretty printers for lldb in `konan_lldb.py`: ``` λ cat main.kt | nl 1 fun main(args: Array<String>) { 2 var x = 1 3 var y = 2 4 var p = Point(x, y) 5 println("p = $p") 6 } 7 data class Point(val x: Int, val y: Int) λ lldb ./program.kexe -o 'b main.kt:5' -o (lldb) target create "./program.kexe" Current executable set to './program.kexe' (x86_64). (lldb) b main.kt:5 Breakpoint 1: where = program.kexe`kfun:main(kotlin.Array<kotlin.String>) + 289 at main.kt:5, address = 0x000000000040af11 (lldb) r Process 4985 stopped * thread #1, name = 'program.kexe', stop reason = breakpoint 1.1 frame #0: program.kexe`kfun:main(kotlin.Array<kotlin.String>) at main.kt:5 2 var x = 1 3 var y = 2 4 var p = Point(x, y) -> 5 println("p = $p") 6 } 7 8 data class Point(val x: Int, val y: Int) Process 4985 launched: './program.kexe' (x86_64) (lldb) fr var (int) x = 1 (int) y = 2 (ObjHeader *) p = 0x00000000007643d8 (lldb) command script import dist/tools/konan_lldb.py (lldb) fr var (int) x = 1 (int) y = 2 (ObjHeader *) p = [x: ..., y: ...] (lldb) p p (ObjHeader *) $2 = [x: ..., y: ...] (lldb) script lldb.frame.FindVariable("p").GetChildMemberWithName("x").Dereference().GetValue() '1' (lldb) ``` Getting representation of the object variable (var) could also be done using the built-in runtime function `Konan_DebugPrint` (this approach also works for gdb, using a module of command syntax): ``` 0:b-debugger-fixes:minamoto@unit-703(0)# cat ../debugger-plugin/1.kt | nl -p 1 fun foo(a:String, b:Int) = a + b 2 fun one() = 1 3 fun main(arg:Array<String>) { 4 var a_variable = foo("(a_variable) one is ", 1) 5 var b_variable = foo("(b_variable) two is ", 2) 6 var c_variable = foo("(c_variable) two is ", 3) 7 var d_variable = foo("(d_variable) two is ", 4) 8 println(a_variable) 9 println(b_variable) 10 println(c_variable) 11 println(d_variable) 12 } 0:b-debugger-fixes:minamoto@unit-703(0)# lldb ./program.kexe -o 'b -f 1.kt -l 9' -o r (lldb) target create "./program.kexe" Current executable set to './program.kexe' (x86_64). (lldb) b -f 1.kt -l 9 Breakpoint 1: where = program.kexe`kfun:main(kotlin.Array<kotlin.String>) + 463 at 1.kt:9, address = 0x0000000100000dbf (lldb) r (a_variable) one is 1 Process 80496 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000dbf program.kexe`kfun:main(kotlin.Array<kotlin.String>) at 1.kt:9 6 var c_variable = foo("(c_variable) two is ", 3) 7 var d_variable = foo("(d_variable) two is ", 4) 8 println(a_variable) -> 9 println(b_variable) 10 println(c_variable) 11 println(d_variable) 12 } Process 80496 launched: './program.kexe' (x86_64) (lldb) expression -- (int32_t)Konan_DebugPrint(a_variable) (a_variable) one is 1(int32_t) $0 = 0 (lldb) ``` Known issues ------------ * performance of Python bindings. Last modified: 10 January 2023 [Concurrency and coroutines](multiplatform-mobile-concurrency-and-coroutines) [Symbolicating iOS crash reports](native-ios-symbolication) kotlin FAQ FAQ === Why KSP? -------- KSP has several advantages over <kapt>: * It is faster. * The API is more fluent for Kotlin users. * It supports [multiple round processing](ksp-multi-round) on generated Kotlin sources. * It is being designed with multiplatform compatibility in mind. Why is KSP faster than kapt? ---------------------------- kapt has to parse and resolve every type reference in order to generate Java stubs, whereas KSP resolves references on-demand. Delegating to javac also takes time. Additionally, KSP's [incremental processing model](ksp-incremental) has a finer granularity than just isolating and aggregating. It finds more opportunities to avoid reprocessing everything. Also, because KSP traces symbol resolutions dynamically, a change in a file is less likely to pollute other files and therefore the set of files to be reprocessed is smaller. This is not possible for kapt because it delegates processing to javac. Is KSP Kotlin-specific? ----------------------- KSP can process Java sources as well. The API is unified, meaning that when you parse a Java class and a Kotlin class you get a unified data structure in KSP. How to upgrade KSP? ------------------- KSP has API and implementation. The API rarely changes and is backward compatible: there can be new interfaces, but old interfaces never change. The implementation is tied to a specific compiler version. With the new release, the supported compiler version can change. Processors only depend on API and therefore are not tied to compiler versions. However, users of processors need to bump KSP version when bumping the compiler version in their project. Otherwise, the following error will occur: ``` ksp-a.b.c is too old for kotlin-x.y.z. Please upgrade ksp or downgrade kotlin-gradle-plugin ``` For example, some processor is released and tested with KSP 1.0.1, which depends strictly on Kotlin 1.6.0. To make it work with Kotlin 1.6.20, the only thing you need to do is bump KSP to a version (for example, KSP 1.1.0) that is built for Kotlin 1.6.20. Can I use a newer KSP implementation with an older Kotlin compiler? ------------------------------------------------------------------- If the language version is the same, Kotlin compiler is supposed to be backward compatible. Bumping Kotlin compiler should be trivial most of the time. If you need a newer KSP implementation, please upgrade the Kotlin compiler accordingly. How often do you update KSP? ---------------------------- KSP tries to follow [Semantic Versioning](https://semver.org/) as close as possible. With KSP version `major.minor.patch`, * `major` is reserved for incompatible API changes. There is no pre-determined schedule for this. * `minor` is reserved for new features. This is going to be updated approximately quarterly. * `patch` is reserved for bug fixes and new Kotlin releases. It's updated roughly monthly. Usually a corresponding KSP release is available within a couple of days after a new Kotlin version is released, including the [pre-releases (Beta or RC)](eap). Besides Kotlin, are there other version requirements to libraries? ------------------------------------------------------------------ Here is a list of requirements for libraries/infrastructures: * Android Gradle Plugin 4.1.0+ * Gradle 6.5+ What is KSP's future roadmap? ----------------------------- The following items have been planned: * Support [new Kotlin compiler](roadmap) * Improve support to multiplatform. For example, running KSP on a subset of targets/sharing computations between targets. * Improve performance. There are a bunch of optimizations to be done! * Keep fixing bugs. Please feel free to reach out to us in the [#ksp channel in Kotlin Slack](https://kotlinlang.slack.com/archives/C013BA8EQSE) ([get an invite](https://surveys.jetbrains.com/s3/kotlin-slack-sign-up)) if you would like to discuss any ideas. Filing [GitHub issues/feature requests](https://github.com/google/ksp/issues) or pull requests are also welcome! Last modified: 10 January 2023 [Running KSP from command line](ksp-command-line) [Kotlin and continuous integration with TeamCity](kotlin-and-ci) kotlin Type-safe builders Type-safe builders ================== By using well-named functions as builders in combination with [function literals with receiver](lambdas#function-literals-with-receiver) it is possible to create type-safe, statically-typed builders in Kotlin. Type-safe builders allow creating Kotlin-based domain-specific languages (DSLs) suitable for building complex hierarchical data structures in a semi-declarative way. Sample use cases for the builders are: * Generating markup with Kotlin code, such as [HTML](https://github.com/Kotlin/kotlinx.html) or XML * Configuring routes for a web server: [Ktor](https://ktor.io/docs/routing.html) Consider the following code: ``` import com.example.html.* // see declarations below fun result() = html { head { title {+"XML encoding with Kotlin"} } body { h1 {+"XML encoding with Kotlin"} p {+"this format can be used as an alternative markup to XML"} // an element with attributes and text content a(href = "https://kotlinlang.org") {+"Kotlin"} // mixed content p { +"This is some" b {+"mixed"} +"text. For more see the" a(href = "https://kotlinlang.org") {+"Kotlin"} +"project" } p {+"some text"} // content generated by p { for (arg in args) +arg } } } ``` This is completely legitimate Kotlin code. You can [play with this code online (modify it and run in the browser) here](https://play.kotlinlang.org/byExample/09_Kotlin_JS/06_HtmlBuilder). How it works ------------ Assume that you need to implement a type-safe builder in Kotlin. First of all, define the model you want to build. In this case you need to model HTML tags. It is easily done with a bunch of classes. For example, `HTML` is a class that describes the `<html>` tag defining children like `<head>` and `<body>`. (See its declaration [below](#full-definition-of-the-com-example-html-package).) Now, let's recall why you can say something like this in the code: ``` html { // ... } ``` `html` is actually a function call that takes a [lambda expression](lambdas) as an argument. This function is defined as follows: ``` fun html(init: HTML.() -> Unit): HTML { val html = HTML() html.init() return html } ``` This function takes one parameter named `init`, which is itself a function. The type of the function is `HTML.() -> Unit`, which is a *function type with receiver*. This means that you need to pass an instance of type `HTML` (a *receiver*) to the function, and you can call members of that instance inside the function. The receiver can be accessed through the `this` keyword: ``` html { this.head { ... } this.body { ... } } ``` (`head` and `body` are member functions of `HTML`.) Now, `this` can be omitted, as usual, and you get something that looks very much like a builder already: ``` html { head { ... } body { ... } } ``` So, what does this call do? Let's look at the body of `html` function as defined above. It creates a new instance of `HTML`, then it initializes it by calling the function that is passed as an argument (in this example this boils down to calling `head` and `body` on the `HTML` instance), and then it returns this instance. This is exactly what a builder should do. The `head` and `body` functions in the `HTML` class are defined similarly to `html`. The only difference is that they add the built instances to the `children` collection of the enclosing `HTML` instance: ``` fun head(init: Head.() -> Unit): Head { val head = Head() head.init() children.add(head) return head } fun body(init: Body.() -> Unit): Body { val body = Body() body.init() children.add(body) return body } ``` Actually these two functions do just the same thing, so you can have a generic version, `initTag`: ``` protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T { tag.init() children.add(tag) return tag } ``` So, now your functions are very simple: ``` fun head(init: Head.() -> Unit) = initTag(Head(), init) fun body(init: Body.() -> Unit) = initTag(Body(), init) ``` And you can use them to build `<head>` and `<body>` tags. One other thing to be discussed here is how you add text to tag bodies. In the example above you say something like: ``` html { head { title {+"XML encoding with Kotlin"} } // ... } ``` So basically, you just put a string inside a tag body, but there is this little `+` in front of it, so it is a function call that invokes a prefix `unaryPlus()` operation. That operation is actually defined by an extension function `unaryPlus()` that is a member of the `TagWithText` abstract class (a parent of `Title`): ``` operator fun String.unaryPlus() { children.add(TextElement(this)) } ``` So, what the prefix `+` does here is wrapping a string into an instance of `TextElement` and adding it to the `children` collection, so that it becomes a proper part of the tag tree. All this is defined in a package `com.example.html` that is imported at the top of the builder example above. In the last section you can read through the full definition of this package. Scope control: @DslMarker ------------------------- When using DSLs, one might have come across the problem that too many functions can be called in the context. You can call methods of every available implicit receiver inside a lambda and therefore get an inconsistent result, like the tag `head` inside another `head`: ``` html { head { head {} // should be forbidden } // ... } ``` In this example only members of the nearest implicit receiver `this@head` must be available; `head()` is a member of the outer receiver `this@html`, so it must be illegal to call it. To address this problem, there is a special mechanism to control receiver scope. To make the compiler start controlling scopes you only have to annotate the types of all receivers used in the DSL with the same marker annotation. For instance, for HTML Builders you declare an annotation `@HTMLTagMarker`: ``` @DslMarker annotation class HtmlTagMarker ``` An annotation class is called a DSL marker if it is annotated with the `@DslMarker` annotation. In our DSL all the tag classes extend the same superclass `Tag`. It's enough to annotate only the superclass with `@HtmlTagMarker` and after that the Kotlin compiler will treat all the inherited classes as annotated: ``` @HtmlTagMarker abstract class Tag(val name: String) { ... } ``` You don't have to annotate the `HTML` or `Head` classes with `@HtmlTagMarker` because their superclass is already annotated: `class HTML() : Tag("html") { ... } class Head() : Tag("head") { ... }` After you've added this annotation, the Kotlin compiler knows which implicit receivers are part of the same DSL and allows to call members of the nearest receivers only: ``` html { head { head { } // error: a member of outer receiver } // ... } ``` Note that it's still possible to call the members of the outer receiver, but to do that you have to specify this receiver explicitly: ``` html { head { [email protected] { } // possible } // ... } ``` Full definition of the com.example.html package ----------------------------------------------- This is how the package `com.example.html` is defined (only the elements used in the example above). It builds an HTML tree. It makes heavy use of [extension functions](extensions) and [lambdas with receiver](lambdas#function-literals-with-receiver). ``` package com.example.html interface Element { fun render(builder: StringBuilder, indent: String) } class TextElement(val text: String) : Element { override fun render(builder: StringBuilder, indent: String) { builder.append("$indent$text\n") } } @DslMarker annotation class HtmlTagMarker @HtmlTagMarker abstract class Tag(val name: String) : Element { val children = arrayListOf<Element>() val attributes = hashMapOf<String, String>() protected fun <T : Element> initTag(tag: T, init: T.() -> Unit): T { tag.init() children.add(tag) return tag } override fun render(builder: StringBuilder, indent: String) { builder.append("$indent<$name${renderAttributes()}>\n") for (c in children) { c.render(builder, indent + " ") } builder.append("$indent</$name>\n") } private fun renderAttributes(): String { val builder = StringBuilder() for ((attr, value) in attributes) { builder.append(" $attr=\"$value\"") } return builder.toString() } override fun toString(): String { val builder = StringBuilder() render(builder, "") return builder.toString() } } abstract class TagWithText(name: String) : Tag(name) { operator fun String.unaryPlus() { children.add(TextElement(this)) } } class HTML : TagWithText("html") { fun head(init: Head.() -> Unit) = initTag(Head(), init) fun body(init: Body.() -> Unit) = initTag(Body(), init) } class Head : TagWithText("head") { fun title(init: Title.() -> Unit) = initTag(Title(), init) } class Title : TagWithText("title") abstract class BodyTag(name: String) : TagWithText(name) { fun b(init: B.() -> Unit) = initTag(B(), init) fun p(init: P.() -> Unit) = initTag(P(), init) fun h1(init: H1.() -> Unit) = initTag(H1(), init) fun a(href: String, init: A.() -> Unit) { val a = initTag(A(), init) a.href = href } } class Body : BodyTag("body") class B : BodyTag("b") class P : BodyTag("p") class H1 : BodyTag("h1") class A : BodyTag("a") { var href: String get() = attributes["href"]!! set(value) { attributes["href"] = value } } fun html(init: HTML.() -> Unit): HTML { val html = HTML() html.init() return html } ``` Last modified: 10 January 2023 [Operator overloading](operator-overloading) [Using builders with builder type inference](using-builders-with-builder-inference)
programming_docs
kotlin What's new in Kotlin 1.5.0 What's new in Kotlin 1.5.0 ========================== *[Release date: 5 May 2021](releases#release-details)* Kotlin 1.5.0 introduces new language features, stable IR-based JVM compiler backend, performance improvements, and evolutionary changes such as stabilizing experimental features and deprecating outdated ones. You can also find an overview of the changes in the [release blog post](https://blog.jetbrains.com/kotlin/2021/04/kotlin-1-5-0-released/). Language features ----------------- Kotlin 1.5.0 brings stable versions of the new language features presented for [preview in 1.4.30](whatsnew1430#language-features): * [JVM records support](#jvm-records-support) * [Sealed interfaces](#sealed-interfaces) and [sealed class improvements](#package-wide-sealed-class-hierarchies) * [Inline classes](#inline-classes) Detailed descriptions of these features are available in [this blog post](https://blog.jetbrains.com/kotlin/2021/02/new-language-features-preview-in-kotlin-1-4-30/) and the corresponding pages of Kotlin documentation. ### JVM records support Java is evolving fast, and to make sure Kotlin remains interoperable with it, we've introduced support for one of its latest features – [record classes](https://openjdk.java.net/jeps/395). Kotlin's support for JVM records includes bidirectional interoperability: * In Kotlin code, you can use Java record classes like you would use typical classes with properties. * To use a Kotlin class as a record in Java code, make it a `data` class and mark it with the `@JvmRecord` annotation. ``` @JvmRecord data class User(val name: String, val age: Int) ``` [Learn more about using JVM records in Kotlin](jvm-records). ### Sealed interfaces Kotlin interfaces can now have the `sealed` modifier, which works on interfaces in the same way it works on classes: all implementations of a sealed interface are known at compile time. ``` sealed interface Polygon ``` You can rely on that fact, for example, to write exhaustive `when` expressions. ``` fun draw(polygon: Polygon) = when (polygon) { is Rectangle -> // ... is Triangle -> // ... // else is not needed - all possible implementations are covered } ``` Additionally, sealed interfaces enable more flexible restricted class hierarchies because a class can directly inherit more than one sealed interface. ``` class FilledRectangle: Polygon, Fillable ``` [Learn more about sealed interfaces](sealed-classes). ### Package-wide sealed class hierarchies Sealed classes can now have subclasses in all files of the same compilation unit and the same package. Previously, all subclasses had to appear in the same file. Direct subclasses may be top-level or nested inside any number of other named classes, named interfaces, or named objects. The subclasses of a sealed class must have a name that is properly qualified – they cannot be local or anonymous objects. [Learn more about sealed class hierarchies](sealed-classes#location-of-direct-subclasses). ### Inline classes Inline classes are a subset of [value-based](https://github.com/Kotlin/KEEP/blob/master/notes/value-classes.md) classes that only hold values. You can use them as wrappers for a value of a certain type without the additional overhead that comes from using memory allocations. Inline classes can be declared with the `value` modifier before the name of the class: ``` value class Password(val s: String) ``` The JVM backend also requires a special `@JvmInline` annotation: ``` @JvmInline value class Password(val s: String) ``` The `inline` modifier is now deprecated with a warning. [Learn more about inline classes](inline-classes). Kotlin/JVM ---------- Kotlin/JVM has received a number of improvements, both internal and user-facing. Here are the most notable among them: * [Stable JVM IR backend](#stable-jvm-ir-backend) * [New default JVM target: 1.8](#new-default-jvm-target-1-8) * [SAM adapters via invokedynamic](#sam-adapters-via-invokedynamic) * [Lambdas via invokedynamic](#lambdas-via-invokedynamic) * [Deprecation of @JvmDefault and old Xjvm-default modes](#deprecation-of-jvmdefault-and-old-xjvm-default-modes) * [Improvements to handling nullability annotations](#improvements-to-handling-nullability-annotations) ### Stable JVM IR backend The [IR-based backend](whatsnew14#new-jvm-ir-backend) for the Kotlin/JVM compiler is now [Stable](components-stability) and enabled by default. Starting from [Kotlin 1.4.0](whatsnew14), early versions of the IR-based backend were available for preview, and it has now become the default for language version `1.5`. The old backend is still used by default for earlier language versions. You can find more details about the benefits of the IR backend and its future development in [this blog post](https://blog.jetbrains.com/kotlin/2021/02/the-jvm-backend-is-in-beta-let-s-make-it-stable-together/). If you need to use the old backend in Kotlin 1.5.0, you can add the following lines to the project's configuration file: * In Gradle: ``` tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile> { kotlinOptions.useOldBackend = true } ``` ``` tasks.withType(org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile) { kotlinOptions.useOldBackend = true } ``` * In Maven: ``` <configuration> <args> <arg>-Xuse-old-backend</arg> </args> </configuration> ``` ### New default JVM target: 1.8 The default target version for Kotlin/JVM compilations is now `1.8`. The `1.6` target is deprecated. If you need a build for JVM 1.6, you can still switch to this target. Learn how: * [in Gradle](gradle-compiler-options#attributes-specific-to-jvm) * [in Maven](maven#attributes-specific-to-jvm) * [in the command-line compiler](compiler-reference#jvm-target-version) ### SAM adapters via invokedynamic Kotlin 1.5.0 now uses dynamic invocations (`invokedynamic`) for compiling SAM (Single Abstract Method) conversions: * Over any expression if the SAM type is a [Java interface](java-interop#sam-conversions) * Over lambda if the SAM type is a [Kotlin functional interface](fun-interfaces#sam-conversions) The new implementation uses [`LambdaMetafactory.metafactory()`](https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/LambdaMetafactory.html#metafactory-java.lang.invoke.MethodHandles.Lookup-java.lang.String-java.lang.invoke.MethodType-java.lang.invoke.MethodType-java.lang.invoke.MethodHandle-java.lang.invoke.MethodType-) and auxiliary wrapper classes are no longer generated during compilation. This decreases the size of the application's JAR, which improves the JVM startup performance. To roll back to the old implementation scheme based on anonymous class generation, add the compiler option `-Xsam-conversions=class`. Learn how to add compiler options in [Gradle](gradle-compiler-options), [Maven](maven#specifying-compiler-options), and the [command-line compiler](compiler-reference#compiler-options). ### Lambdas via invokedynamic Kotlin 1.5.0 is introducing experimental support for compiling plain Kotlin lambdas (which are not converted to an instance of a functional interface) into dynamic invocations (`invokedynamic`). The implementation produces lighter binaries by using [`LambdaMetafactory.metafactory()`](https://docs.oracle.com/javase/8/docs/api/java/lang/invoke/LambdaMetafactory.html#metafactory-java.lang.invoke.MethodHandles.Lookup-java.lang.String-java.lang.invoke.MethodType-java.lang.invoke.MethodType-java.lang.invoke.MethodHandle-java.lang.invoke.MethodType-), which effectively generates the necessary classes at runtime. Currently, it has three limitations compared to ordinary lambda compilation: * A lambda compiled into invokedynamic is not serializable. * Calling `toString()` on such a lambda produces a less readable string representation. * Experimental [`reflect`](../api/latest/jvm/stdlib/kotlin.reflect.jvm/reflect) API does not support lambdas created with `LambdaMetafactory`. To try this feature, add the `-Xlambdas=indy` compiler option. We would be grateful if you could share your feedback on it using this [YouTrack ticket](https://youtrack.jetbrains.com/issue/KT-45375). Learn how to add compiler options in [Gradle](gradle-compiler-options), [Maven](maven#specifying-compiler-options), and [command-line compiler](compiler-reference#compiler-options). ### Deprecation of @JvmDefault and old Xjvm-default modes Prior to Kotlin 1.4.0, there was the `@JvmDefault` annotation along with `-Xjvm-default=enable` and `-Xjvm-default=compatibility` modes. They served to create the JVM default method for any particular non-abstract member in the Kotlin interface. In Kotlin 1.4.0, we [introduced the new `Xjvm-default` modes](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/), which switch on default method generation for the whole project. In Kotlin 1.5.0, we are deprecating `@JvmDefault` and the old Xjvm-default modes: `-Xjvm-default=enable` and `-Xjvm-default=compatibility`. [Learn more about default methods in the Java interop](java-to-kotlin-interop#default-methods-in-interfaces). ### Improvements to handling nullability annotations Kotlin supports handling type nullability information from Java with [nullability annotations](java-interop#nullability-annotations). Kotlin 1.5.0 introduces a number of improvements for the feature: * It reads nullability annotations on type arguments in compiled Java libraries that are used as dependencies. * It supports nullability annotations with the `TYPE_USE` target for: + Arrays + Varargs + Fields + Type parameters and their bounds + Type arguments of base classes and interfaces * If a nullability annotation has multiple targets applicable to a type, and one of these targets is `TYPE_USE`, then `TYPE_USE` is preferred. For example, the method signature `@Nullable String[] f()` becomes `fun f(): Array<String?>!` if `@Nullable` supports both `TYPE_USE` and `METHOD`as targets. For these newly supported cases, using the wrong type nullability when calling Java from Kotlin produces warnings. Use the `-Xtype-enhancement-improvements-strict-mode` compiler option to enable strict mode for these cases (with error reporting). [Learn more about null-safety and platform types](java-interop#null-safety-and-platform-types). Kotlin/Native ------------- Kotlin/Native is now more performant and stable. The notable changes are: * [Performance improvements](#performance-improvements) * [Deactivation of the memory leak checker](#deactivation-of-the-memory-leak-checker) ### Performance improvements In 1.5.0, Kotlin/Native is receiving a set of performance improvements that speed up both compilation and execution. [Compiler caches](https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-3-70-released/#kotlin-native) are now supported in debug mode for `linuxX64` (only on Linux hosts) and `iosArm64` targets. With compiler caches enabled, most debug compilations complete much faster, except for the first one. Measurements showed about a 200% speed increase on our test projects. To use compiler caches for new targets, opt in by adding the following lines to the project's `gradle.properties`: * For `linuxX64`: `kotlin.native.cacheKind.linuxX64=static` * For `iosArm64`: `kotlin.native.cacheKind.iosArm64=static` If you encounter any issues after enabling the compiler caches, please report them to our issue tracker [YouTrack](https://kotl.in/issue). Other improvements speed up the execution of Kotlin/Native code: * Trivial property accessors are inlined. * `trimIndent()` on string literals is evaluated during the compilation. ### Deactivation of the memory leak checker The built-in Kotlin/Native memory leak checker has been disabled by default. It was initially designed for internal use, and it is able to find leaks only in a limited number of cases, not all of them. Moreover, it later turned out to have issues that can cause application crashes. So we've decided to turn off the memory leak checker. The memory leak checker can still be useful for certain cases, for example, unit testing. For these cases, you can enable it by adding the following line of code: ``` Platform.isMemoryLeakCheckerActive = true ``` Note that enabling the checker for the application runtime is not recommended. Kotlin/JS --------- Kotlin/JS is receiving evolutionary changes in 1.5.0. We're continuing our work on moving the [JS IR compiler backend](js-ir-compiler) towards stable and shipping other updates: * [Upgrade of webpack to version 5](#upgrade-to-webpack-5) * [Frameworks and libraries for the IR compiler](#frameworks-and-libraries-for-the-ir-compiler) ### Upgrade to webpack 5 The Kotlin/JS Gradle plugin now uses webpack 5 for browser targets instead of webpack 4. This is a major webpack upgrade that brings incompatible changes. If you're using a custom webpack configuration, be sure to check the [webpack 5 release notes](https://webpack.js.org/blog/2020-10-10-webpack-5-release/). [Learn more about bundling Kotlin/JS projects with webpack](js-project-setup#webpack-bundling). ### Frameworks and libraries for the IR compiler Along with working on the IR-based backend for Kotlin/JS compiler, we encourage and help library authors to build their projects in `both` mode. This means they are able to produce artifacts for both Kotlin/JS compilers, therefore growing the ecosystem for the new compiler. Many well-known frameworks and libraries are already available for the IR backend: [KVision](https://kvision.io/), [fritz2](https://www.fritz2.dev/), [doodle](https://github.com/nacular/doodle), and others. If you're using them in your project, you can already build it with the IR backend and see the benefits it brings. If you're writing your own library, [compile it in the 'both' mode](js-ir-compiler#authoring-libraries-for-the-ir-compiler-with-backwards-compatibility) so that your clients can also use it with the new compiler. Kotlin Multiplatform -------------------- In Kotlin 1.5.0, [choosing a testing dependency for each platform has been simplified](#simplified-test-dependencies-usage-in-multiplatform-projects) and it is now done automatically by the Gradle plugin. A new [API for getting a char category is now available in multiplatform projects](#new-api-for-getting-a-char-category-now-available-in-multiplatform-code). Standard library ---------------- The standard library has received a range of changes and improvements, from stabilizing experimental parts to adding new features: * [Stable unsigned integer types](#stable-unsigned-integer-types) * [Stable locale-agnostic API for uppercase/lowercase text](#stable-locale-agnostic-api-for-upper-lowercasing-text) * [Stable Char-to-integer conversion API](#stable-char-to-integer-conversion-api) * [Stable Path API](#stable-path-api) * [Floored division and the mod operator](#floored-division-and-the-mod-operator) * [Duration API changes](#duration-api-changes) * [New API for getting a char category now available in multiplatform code](#new-api-for-getting-a-char-category-now-available-in-multiplatform-code) * [New collections function firstNotNullOf()](#new-collections-function-firstnotnullof) * [Strict version of String?.toBoolean()](#strict-version-of-string-toboolean) You can learn more about the standard library changes in [this blog post](https://blog.jetbrains.com/kotlin/2021/04/kotlin-1-5-0-rc-released). ### Stable unsigned integer types The `UInt`, `ULong`, `UByte`, `UShort` unsigned integer types are now [Stable](components-stability). The same goes for operations on these types, ranges, and progressions of them. Unsigned arrays and operations on them remain in Beta. [Learn more about unsigned integer types](unsigned-integer-types). ### Stable locale-agnostic API for upper/lowercasing text This release brings a new locale-agnostic API for uppercase/lowercase text conversion. It provides an alternative to the `toLowerCase()`, `toUpperCase()`, `capitalize()`, and `decapitalize()` API functions, which are locale-sensitive. The new API helps you avoid errors due to different locale settings. Kotlin 1.5.0 provides the following fully [Stable](components-stability) alternatives: * For `String` functions: | **Earlier versions** | **1.5.0 alternative** | | --- | --- | | `String.toUpperCase()` | `String.uppercase()` | | `String.toLowerCase()` | `String.lowercase()` | | `String.capitalize()` | `String.replaceFirstChar { it.uppercase() }` | | `String.decapitalize()` | `String.replaceFirstChar { it.lowercase() }` | * For `Char` functions: | **Earlier versions** | **1.5.0 alternative** | | --- | --- | | `Char.toUpperCase()` | `Char.uppercaseChar(): Char``Char.uppercase(): String` | | `Char.toLowerCase()` | `Char.lowercaseChar(): Char``Char.lowercase(): String` | | `Char.toTitleCase()` | `Char.titlecaseChar(): Char``Char.titlecase(): String` | The old API functions are marked as deprecated and will be removed in a future release. See the full list of changes to the text processing functions in [KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/locale-agnostic-case-conversions.md). ### Stable char-to-integer conversion API Starting from Kotlin 1.5.0, new char-to-code and char-to-digit conversion functions are [Stable](components-stability). These functions replace the current API functions, which were often confused with the similar string-to-Int conversion. The new API removes this naming confusion, making the code behavior more transparent and unambiguous. This release introduces `Char` conversions that are divided into the following sets of clearly named functions: * Functions to get the integer code of `Char` and to construct `Char` from the given code: ``` fun Char(code: Int): Char fun Char(code: UShort): Char val Char.code: Int ``` * Functions to convert `Char` to the numeric value of the digit it represents: ``` fun Char.digitToInt(radix: Int): Int fun Char.digitToIntOrNull(radix: Int): Int? ``` * An extension function for `Int` to convert the non-negative single digit it represents to the corresponding `Char` representation: ``` fun Int.digitToChar(radix: Int): Char ``` The old conversion APIs, including `Number.toChar()` with its implementations (all except `Int.toChar()`) and `Char` extensions for conversion to a numeric type, like `Char.toInt()`, are now deprecated. [Learn more about the char-to-integer conversion API in KEEP](https://github.com/Kotlin/KEEP/blob/master/proposals/stdlib/char-int-conversions.md). ### Stable Path API The [experimental Path API](../api/latest/jvm/stdlib/kotlin.io.path/java.nio.file.-path/index) with extensions for `java.nio.file.Path` is now [Stable](components-stability). ``` // construct path with the div (/) operator val baseDir = Path("/base") val subDir = baseDir / "subdirectory" // list files in a directory val kotlinFiles: List<Path> = Path("/home/user").listDirectoryEntries("*.kt") ``` [Learn more about the Path API](whatsnew1420#extensions-for-java-nio-file-path). ### Floored division and the mod operator New operations for modular arithmetics have been added to the standard library: * `floorDiv()` returns the result of [floored division](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions). It is available for integer types. * `mod()` returns the remainder of floored division (*modulus*). It is available for all numeric types. These operations look quite similar to the existing [division of integers](numbers#operations-on-numbers) and [rem()](../api/latest/jvm/stdlib/kotlin/-int/rem) function (or the `%`operator), but they work differently on negative numbers: * `a.floorDiv(b)` differs from a regular `/` in that `floorDiv` rounds the result down (towards the lesser integer), whereas `/` truncates the result to the integer closer to 0. * `a.mod(b)` is the difference between `a` and `a.floorDiv(b) * b`. It's either zero or has the same sign as `b`, while `a % b` can have a different one. ``` fun main() { //sampleStart println("Floored division -5/3: ${(-5).floorDiv(3)}") println( "Modulus: ${(-5).mod(3)}") println("Truncated division -5/3: ${-5 / 3}") println( "Remainder: ${-5 % 3}") //sampleEnd } ``` ### Duration API changes There is an experimental [Duration](../api/latest/jvm/stdlib/kotlin.time/-duration/index) class for representing duration amounts in different time units. In 1.5.0, the Duration API has received the following changes: * Internal value representation now uses `Long` instead of `Double` to provide better precision. * There is a new API for conversion to a particular time unit in `Long`. It comes to replace the old API, which operates with `Double` values and is now deprecated. For example, [`Duration.inWholeMinutes`](../api/latest/jvm/stdlib/kotlin.time/-duration/in-whole-minutes) returns the value of the duration expressed as `Long` and replaces `Duration.inMinutes`. * There are new companion functions for constructing a `Duration` from a number. For example, [`Duration.seconds(Int)`](../api/latest/jvm/stdlib/kotlin.time/-duration/seconds) creates a `Duration` object representing an integer number of seconds. Old extension properties like `Int.seconds` are now deprecated. ``` import kotlin.time.Duration import kotlin.time.ExperimentalTime @ExperimentalTime fun main() { //sampleStart val duration = Duration.milliseconds(120000) println("There are ${duration.inWholeSeconds} seconds in ${duration.inWholeMinutes} minutes") //sampleEnd } ``` ### New API for getting a char category now available in multiplatform code Kotlin 1.5.0 introduces the new API for getting a character's category according to Unicode in multiplatform projects. Several functions are now available in all the platforms and in the common code. Functions for checking whether a char is a letter or a digit: * [`Char.isDigit()`](../api/latest/jvm/stdlib/kotlin.text/is-digit) * [`Char.isLetter()`](../api/latest/jvm/stdlib/kotlin.text/is-letter) * [`Char.isLetterOrDigit()`](../api/latest/jvm/stdlib/kotlin.text/is-letter-or-digit) ``` fun main() { //sampleStart val chars = listOf('a', '1', '+') val (letterOrDigitList, notLetterOrDigitList) = chars.partition { it.isLetterOrDigit() } println(letterOrDigitList) // [a, 1] println(notLetterOrDigitList) // [+] //sampleEnd } ``` Functions for checking the case of a char: * [`Char.isLowerCase()`](../api/latest/jvm/stdlib/kotlin.text/is-lower-case) * [`Char.isUpperCase()`](../api/latest/jvm/stdlib/kotlin.text/is-upper-case) * [`Char.isTitleCase()`](../api/latest/jvm/stdlib/kotlin.text/is-title-case) ``` fun main() { //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 } ``` Some other functions: * [`Char.isDefined()`](../api/latest/jvm/stdlib/kotlin.text/is-defined) * [`Char.isISOControl()`](../api/latest/jvm/stdlib/kotlin.text/is-i-s-o-control) The property [`Char.category`](../api/latest/jvm/stdlib/kotlin.text/category) and its return type enum class [`CharCategory`](../api/latest/jvm/stdlib/kotlin.text/-char-category/index), which indicates a char's general category according to Unicode, are now also available in multiplatform projects. [Learn more about characters](characters). ### New collections function firstNotNullOf() The new [`firstNotNullOf()`](../api/latest/jvm/stdlib/kotlin.collections/first-not-null-of) and [`firstNotNullOfOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/first-not-null-of-or-null) functions combine [`mapNotNull()`](../api/latest/jvm/stdlib/kotlin.collections/map-not-null) with [`first()`](../api/latest/jvm/stdlib/kotlin.collections/first) or [`firstOrNull()`](../api/latest/jvm/stdlib/kotlin.collections/first-or-null). They map the original collection with the custom selector function and return the first non-null value. If there is no such value, `firstNotNullOf()` throws an exception, and `firstNotNullOfOrNull()` returns null. ``` fun main() { //sampleStart val data = listOf("Kotlin", "1.5") println(data.firstNotNullOf(String::toDoubleOrNull)) println(data.firstNotNullOfOrNull(String::toIntOrNull)) //sampleEnd } ``` ### Strict version of String?.toBoolean() Two new functions introduce case-sensitive strict versions of the existing [String?.toBoolean()](../api/latest/jvm/stdlib/kotlin.text/to-boolean): * [`String.toBooleanStrict()`](../api/latest/jvm/stdlib/kotlin.text/to-boolean-strict) throws an exception for all inputs except the literals `true` and `false`. * [`String.toBooleanStrictOrNull()`](../api/latest/jvm/stdlib/kotlin.text/to-boolean-strict-or-null) returns null for all inputs except the literals `true` and `false`. ``` fun main() { //sampleStart println("true".toBooleanStrict()) println("1".toBooleanStrictOrNull()) // println("1".toBooleanStrict()) // Exception //sampleEnd } ``` kotlin-test library ------------------- The [kotlin-test](https://kotlinlang.org/api/latest/kotlin.test/) library introduces some new features: * [Simplified test dependencies usage in multiplatform projects](#simplified-test-dependencies-usage-in-multiplatform-projects) * [Automatic selection of a testing framework for Kotlin/JVM source sets](#automatic-selection-of-a-testing-framework-for-kotlin-jvm-source-sets) * [Assertion function updates](#assertion-function-updates) ### Simplified test dependencies usage in multiplatform projects Now you can use the `kotlin-test` dependency to add dependencies for testing in the `commonTest` source set, and the Gradle plugin will infer the corresponding platform dependencies for each test source set: * `kotlin-test-junit` for JVM source sets, see [automatic choice of a testing framework for Kotlin/JVM source sets](#automatic-selection-of-a-testing-framework-for-kotlin-jvm-source-sets) * `kotlin-test-js` for Kotlin/JS source sets * `kotlin-test-common` and `kotlin-test-annotations-common` for common source sets * No extra artifact for Kotlin/Native source sets Additionally, you can use the `kotlin-test` dependency in any shared or platform-specific source set. An existing kotlin-test setup with explicit dependencies will continue to work both in Gradle and in Maven. Learn more about [setting dependencies on test libraries](gradle-configure-project#set-dependencies-on-test-libraries). ### Automatic selection of a testing framework for Kotlin/JVM source sets The Gradle plugin now chooses and adds a dependency on a testing framework automatically. All you need to do is add the dependency `kotlin-test` in the common source set. Gradle uses JUnit 4 by default. Therefore, the `kotlin("test")` dependency resolves to the variant for JUnit 4, namely `kotlin-test-junit`: ``` kotlin { sourceSets { val commonTest by getting { dependencies { implementation(kotlin("test")) // This brings the dependency // on JUnit 4 transitively } } } } ``` ``` kotlin { sourceSets { commonTest { dependencies { implementation kotlin("test") // This brings the dependency // on JUnit 4 transitively } } } } ``` You can choose JUnit 5 or TestNG by calling [`useJUnitPlatform()`](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html#useJUnitPlatform) or [`useTestNG()`](https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/Test.html#useTestNG) in the test task: ``` tasks { test { // enable TestNG support useTestNG() // or // enable JUnit Platform (a.k.a. JUnit 5) support useJUnitPlatform() } } ``` You can disable automatic testing framework selection by adding the line `kotlin.test.infer.jvm.variant=false` to the project's `gradle.properties`. Learn more about [setting dependencies on test libraries](gradle-configure-project#set-dependencies-on-test-libraries). ### Assertion function updates This release brings new assertion functions and improves the existing ones. The `kotlin-test` library now has the following features: * **Checking the type of a value** You can use the new `assertIs<T>` and `assertIsNot<T>` to check the type of a value: ``` @Test fun testFunction() { val s: Any = "test" assertIs<String>(s) // throws AssertionError mentioning the actual type of s if the assertion fails // can now print s.length because of contract in assertIs println("${s.length}") } ``` Because of type erasure, this assert function only checks whether the `value` is of the `List` type in the following example and doesn't check whether it's a list of the particular `String` element type: `assertIs<List<String>>(value)`. * **Comparing the container content for arrays, sequences, and arbitrary iterables** There is a new set of overloaded `assertContentEquals()` functions for comparing content for different collections that don't implement [structural equality](equality#structural-equality): ``` @Test fun test() { val expectedArray = arrayOf(1, 2, 3) val actualArray = Array(3) { it + 1 } assertContentEquals(expectedArray, actualArray) } ``` * **New overloads to `assertEquals()` and `assertNotEquals()` for `Double` and `Float` numbers** There are new overloads for the `assertEquals()` function that make it possible to compare two `Double` or `Float` numbers with absolute precision. The precision value is specified as the third parameter of the function: ``` @Test fun test() { val x = sin(PI) // precision parameter val tolerance = 0.000001 assertEquals(0.0, x, tolerance) } ``` * **New functions for checking the content of collections and elements** You can now check whether the collection or element contains something with the `assertContains()` function. You can use it with Kotlin collections and elements that have the `contains()` operator, such as `IntRange`, `String`, and others: ``` @Test fun test() { val sampleList = listOf<String>("sample", "sample2") val sampleString = "sample" assertContains(sampleList, sampleString) // element in collection assertContains(sampleString, "amp") // substring in string } ``` * **`assertTrue()`, `assertFalse()`, `expect()` functions are now inline** From now on, you can use these as inline functions, so it's possible to call [suspend functions](composing-suspending-functions) inside a lambda expression: ``` @Test fun test() = runBlocking<Unit> { val deferred = async { "Kotlin is nice" } assertTrue("Kotlin substring should be present") { deferred.await() .contains("Kotlin") } } ``` kotlinx libraries ----------------- Along with Kotlin 1.5.0, we are releasing new versions of the kotlinx libraries: * `kotlinx.coroutines` [1.5.0-RC](#coroutines-1-5-0-rc) * `kotlinx.serialization` [1.2.1](#serialization-1-2-1) * `kotlinx-datetime` [0.2.0](#datetime-0-2-0) ### Coroutines 1.5.0-RC `kotlinx.coroutines` [1.5.0-RC](https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.5.0-RC) is here with: * [New channels API](channels) * Stable [reactive integrations](async-programming#reactive-extensions) * And more Starting with Kotlin 1.5.0, [experimental coroutines](whatsnew14#exclusion-of-the-deprecated-experimental-coroutines) are disabled and the `-Xcoroutines=experimental` flag is no longer supported. Learn more in the [changelog](https://github.com/Kotlin/kotlinx.coroutines/releases/tag/1.5.0-RC) and the [`kotlinx.coroutines` 1.5.0 release blog post](https://blog.jetbrains.com/kotlin/2021/05/kotlin-coroutines-1-5-0-released/). ### Serialization 1.2.1 `kotlinx.serialization` [1.2.1](https://github.com/Kotlin/kotlinx.serialization/releases/tag/v1.2.1) is here with: * Improvements to JSON serialization performance * Support for multiple names in JSON serialization * Experimental .proto schema generation from `@Serializable` classes * And more Learn more in the [changelog](https://github.com/Kotlin/kotlinx.serialization/releases/tag/v1.2.1) and the [`kotlinx.serialization` 1.2.1 release blog post](https://blog.jetbrains.com/kotlin/2021/05/kotlinx-serialization-1-2-released/). ### dateTime 0.2.0 `kotlinx-datetime` [0.2.0](https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.2.0) is here with: * `@Serializable` Datetime objects * Normalized API of `DateTimePeriod` and `DatePeriod` * And more Learn more in the [changelog](https://github.com/Kotlin/kotlinx-datetime/releases/tag/v0.2.0) and the [`kotlinx-datetime` 0.2.0 release blog post](https://blog.jetbrains.com/kotlin/2021/05/kotlinx-datetime-0-2-0-is-out/). Migrating to Kotlin 1.5.0 ------------------------- IntelliJ IDEA and Android Studio will suggest updating the Kotlin plugin to 1.5.0 once it is available. To migrate existing projects to Kotlin 1.5.0, just change the Kotlin version to `1.5.0` and re-import your Gradle or Maven project. [Learn how to update to Kotlin 1.5.0](releases#update-to-a-new-release). To start a new project with Kotlin 1.5.0, update the Kotlin plugin and run the Project Wizard from **File** | **New** | **Project**. The new command-line compiler is available for downloading on the [GitHub release page](https://github.com/JetBrains/kotlin/releases/tag/v1.5.0). Kotlin 1.5.0 is a [feature release](kotlin-evolution#feature-releases-and-incremental-releases) and therefore can bring incompatible changes to the language. Find the detailed list of such changes in the [Compatibility Guide for Kotlin 1.5](compatibility-guide-15). Last modified: 10 January 2023 [What's new in Kotlin 1.5.20](whatsnew1520) [What's new in Kotlin 1.4.30](whatsnew1430)
programming_docs
kotlin Debug coroutines using IntelliJ IDEA – tutorial Debug coroutines using IntelliJ IDEA – tutorial =============================================== This tutorial demonstrates how to create Kotlin coroutines and debug them using IntelliJ IDEA. The tutorial assumes you have prior knowledge of the [coroutines](coroutines-guide) concept. Create coroutines ----------------- 1. Open a Kotlin project in IntelliJ IDEA. If you don't have a project, [create one](jvm-get-started#create-a-project). 2. To use the `kotlinx.coroutines` library in a Gradle project, add the following dependency to `build.gradle(.kts)`: ``` dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") } ``` ``` dependencies { implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4' } ``` For other build systems, see instructions in the [`kotlinx.coroutines` README](https://github.com/Kotlin/kotlinx.coroutines#using-in-your-projects). 3. Open the `Main.kt` file in `src/main/kotlin`. The `src` directory contains Kotlin source files and resources. The `Main.kt` file contains sample code that will print `Hello World!`. 4. Change code in the `main()` function: * Use the [`runBlocking()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/run-blocking.html) block to wrap a coroutine. * Use the [`async()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/async.html) function to create coroutines that compute deferred values `a` and `b`. * Use the [`await()`](https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/await.html) function to await the computation result. * Use the [`println()`](../api/latest/jvm/stdlib/kotlin.io/println) function to print computing status and the result of multiplication to the output. ``` import kotlinx.coroutines.* fun main() = runBlocking<Unit> { val a = async { println("I'm computing part of the answer") 6 } val b = async { println("I'm computing another part of the answer") 7 } println("The answer is ${a.await() * b.await()}") } ``` 5. Build the code by clicking **Build Project**. ![Build an application](https://kotlinlang.org/docs/images/flow-build-project.png "Build an application") Debug coroutines ---------------- 1. Set breakpoints at the lines with the `println()` function call: ![Build a console application](https://kotlinlang.org/docs/images/coroutine-breakpoint.png "Build a console application") 2. Run the code in debug mode by clicking **Debug** next to the run configuration at the top of the screen. ![Build a console application](https://kotlinlang.org/docs/images/flow-debug-project.png "Build a console application")The **Debug** tool window appears: * The **Frames** tab contains the call stack. * The **Variables** tab contains variables in the current context. * The **Coroutines** tab contains information on running or suspended coroutines. It shows that there are three coroutines. The first one has the **RUNNING** status, and the other two have the **CREATED** status.![Debug the coroutine](https://kotlinlang.org/docs/images/coroutine-debug-1.png "Debug the coroutine") 3. Resume the debugger session by clicking **Resume Program** in the **Debug** tool window: ![Debug the coroutine](https://kotlinlang.org/docs/images/coroutine-debug-2.png "Debug the coroutine")Now the **Coroutines** tab shows the following: * The first coroutine has the **SUSPENDED** status – it is waiting for the values so it can multiply them. * The second coroutine is calculating the `a` value – it has the **RUNNING** status. * The third coroutine has the **CREATED** status and isn’t calculating the value of `b`. 4. Resume the debugger session by clicking **Resume Program** in the **Debug** tool window: ![Build a console application](https://kotlinlang.org/docs/images/coroutine-debug-3.png "Build a console application")Now the **Coroutines** tab shows the following: * The first coroutine has the **SUSPENDED** status – it is waiting for the values so it can multiply them. * The second coroutine has computed its value and disappeared. * The third coroutine is calculating the value of `b` – it has the **RUNNING** status. Using IntelliJ IDEA debugger, you can dig deeper into each coroutine to debug your code. ### Optimized-out variables If you use `suspend` functions, in the debugger, you might see the "was optimized out" text next to a variable's name: ![Variable "a" was optimized out](https://kotlinlang.org/docs/images/variable-optimised-out.png "Variable \"a\" was optimized out")This text means that the variable's lifetime was decreased, and the variable doesn't exist anymore. It is difficult to debug code with optimized variables because you don't see their values. You can disable this behavior with the `-Xdebug` compiler option. Last modified: 10 January 2023 [Select expression (experimental)](select-expression) [Debug Kotlin Flow using IntelliJ IDEA – tutorial](debug-flow-with-idea) kotlin Generation of external declarations with Dukat Generation of external declarations with Dukat ============================================== [Dukat](https://github.com/kotlin/dukat) is a tool currently in development which allows the automatic conversion of TypeScript declaration files (`.d.ts`) into Kotlin external declarations. This aims to makes it more comfortable to use libraries from the JavaScript ecosystem in a type-safe manner in Kotlin, reducing the need for manually writing external declarations and wrappers for JS libraries. The Kotlin/JS Gradle plugin provides an integration with Dukat. When enabled, type-safe Kotlin external declarations are automatically generated for npm dependencies that provide TypeScript definitions. You have two different ways of selecting if and when Dukat should generate declarations: at build time, and manually via a Gradle task. Generate external declarations at build time -------------------------------------------- The `npm` dependency function takes a third parameter after the package name and version: `generateExternals`. This allows you to control whether Dukat should generate declarations for a specific dependency: ``` dependencies { implementation(npm("decamelize", "4.0.0", generateExternals = true)) } ``` ``` dependencies { implementation(npm('decamelize', '4.0.0', true)) } ``` If the repository of the dependency you wish to use does not provide TypeScript definitions, you can also use types provided via the [DefinitelyTyped](https://github.com/DefinitelyTyped/DefinitelyTyped) repository. In this case, make sure you add `npm` dependencies for both `your-package` and `@types/your-package` (with `generateExternals = true`). You can use the option `kotlin.js.generate.externals` in your `gradle.properties` file to set the generator's behavior for all npm dependencies simultaneously. As usual, individual explicit settings take precedence over this general option. Manually generate external declarations via Gradle task ------------------------------------------------------- If you want to have full control over the declarations generated by Dukat, want to apply manual adjustments, or if you're running into trouble with the auto-generated externals, you can also trigger the creation of the declarations for all your npm dependencies manually via the Gradle task `generateExternals` (`jsGenerateExternals` with the multiplatform plugin). This will generate declarations in a directory titled `externals` in your project root. Here, you can review the generated code and copy any parts you would like to use to your source directories. It is recommended to only provide external declarations manually in your source folder *or* enabling the generation of external declarations at build time for any single dependency. Doing both can result in resolution issues. Last modified: 10 January 2023 [Typesafe HTML DSL](typesafe-html-dsl) [Samples](js-samples) kotlin ln ln == [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <ln> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun ln(x: Double): Double ``` ``` fun ln(x: Float): Float ``` Computes the natural logarithm (base `E`) of the value [x](ln#kotlin.math%24ln(kotlin.Double)/x). Special cases: * `ln(NaN)` is `NaN` * `ln(x)` is `NaN` when `x < 0.0` * `ln(+Inf)` is `+Inf` * `ln(0.0)` is `-Inf` kotlin atan atan ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <atan> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun atan(x: Double): Double ``` ``` fun atan(x: Float): Float ``` Computes the arc tangent of the value [x](atan#kotlin.math%24atan(kotlin.Double)/x); the returned value is an angle in the range from `-PI/2` to `PI/2` radians. Special cases: * `atan(NaN)` is `NaN` kotlin E E = [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [E](-e) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` const val E: Double ``` Base of the natural logarithms, approximately 2.71828. kotlin asin asin ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <asin> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun asin(x: Double): Double ``` ``` fun asin(x: Float): Float ``` Computes the arc sine of the value [x](asin#kotlin.math%24asin(kotlin.Double)/x); the returned value is an angle in the range from `-PI/2` to `PI/2` radians. Special cases: - `asin(x)` is `NaN`, when `abs(x) > 1` or x is `NaN` kotlin cosh cosh ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <cosh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun cosh(x: Double): Double ``` ``` fun cosh(x: Float): Float ``` Computes the hyperbolic cosine of the value [x](cosh#kotlin.math%24cosh(kotlin.Double)/x). Special cases: * `cosh(NaN)` is `NaN` * `cosh(+Inf|-Inf)` is `+Inf` kotlin asinh asinh ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <asinh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun asinh(x: Double): Double ``` ``` fun asinh(x: Float): Float ``` Computes the inverse hyperbolic sine of the value [x](asinh#kotlin.math%24asinh(kotlin.Double)/x). The returned value is `y` such that `sinh(y) == x`. Special cases: * `asinh(NaN)` is `NaN` * `asinh(+Inf)` is `+Inf` * `asinh(-Inf)` is `-Inf` kotlin log2 log2 ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <log2> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun log2(x: Double): Double ``` ``` fun log2(x: Float): Float ``` Computes the binary logarithm (base 2) of the value [x](log2#kotlin.math%24log2(kotlin.Double)/x). **See Also** [ln](ln#kotlin.math%24ln(kotlin.Double)) kotlin Package kotlin.math Package kotlin.math =================== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) Mathematical functions and constants. The functions include trigonometric, hyperbolic, exponentiation and power, logarithmic, rounding, sign and absolute value. Properties ---------- **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [absoluteValue](absolute-value) Returns the absolute value of this value. ``` val Double.absoluteValue: Double ``` ``` val Float.absoluteValue: Float ``` ``` val Int.absoluteValue: Int ``` ``` val Long.absoluteValue: Long ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [E](-e) Base of the natural logarithms, approximately 2.71828. ``` const val E: Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [PI](-p-i) Ratio of the circumference of a circle to its diameter, approximately 3.14159. ``` const val PI: Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <sign> Returns the sign of this value: ``` val Double.sign: Double ``` ``` val Float.sign: Float ``` ``` val Int.sign: Int ``` ``` val Long.sign: Int ``` #### <ulp> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) Returns the ulp (unit in the last place) of this value. ``` val Double.ulp: Double ``` **Platform and version requirements:** JVM (1.2), Native (1.2) Returns the ulp of this value. ``` val Float.ulp: Float ``` Functions --------- **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <abs> Returns the absolute value of the given value [x](abs#kotlin.math%24abs(kotlin.Double)/x). ``` fun abs(x: Double): Double ``` ``` fun abs(x: Float): Float ``` Returns the absolute value of the given value [n](abs#kotlin.math%24abs(kotlin.Int)/n). ``` fun abs(n: Int): Int ``` ``` fun abs(n: Long): Long ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <acos> Computes the arc cosine of the value [x](acos#kotlin.math%24acos(kotlin.Double)/x); the returned value is an angle in the range from `0.0` to `PI` radians. ``` fun acos(x: Double): Double ``` ``` fun acos(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <acosh> Computes the inverse hyperbolic cosine of the value [x](acosh#kotlin.math%24acosh(kotlin.Double)/x). ``` fun acosh(x: Double): Double ``` ``` fun acosh(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <asin> Computes the arc sine of the value [x](asin#kotlin.math%24asin(kotlin.Double)/x); the returned value is an angle in the range from `-PI/2` to `PI/2` radians. ``` fun asin(x: Double): Double ``` ``` fun asin(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <asinh> Computes the inverse hyperbolic sine of the value [x](asinh#kotlin.math%24asinh(kotlin.Double)/x). ``` fun asinh(x: Double): Double ``` ``` fun asinh(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <atan> Computes the arc tangent of the value [x](atan#kotlin.math%24atan(kotlin.Double)/x); the returned value is an angle in the range from `-PI/2` to `PI/2` radians. ``` fun atan(x: Double): Double ``` ``` fun atan(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <atan2> Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y](atan2#kotlin.math%24atan2(kotlin.Double,%20kotlin.Double)/y) / [x](atan2#kotlin.math%24atan2(kotlin.Double,%20kotlin.Double)/x); the returned value is an angle in the range from `-PI` to `PI` radians. ``` fun atan2(y: Double, x: Double): Double ``` ``` fun atan2(y: Float, x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <atanh> Computes the inverse hyperbolic tangent of the value [x](atanh#kotlin.math%24atanh(kotlin.Double)/x). ``` fun atanh(x: Double): Double ``` ``` fun atanh(x: Float): Float ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### <cbrt> Returns the cube root of [x](cbrt#kotlin.math%24cbrt(kotlin.Double)/x). For any `x`, `cbrt(-x) == -cbrt(x)`; that is, the cube root of a negative value is the negative of the cube root of that value's magnitude. Special cases: ``` fun cbrt(x: Double): Double ``` ``` fun cbrt(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <ceil> Rounds the given value [x](ceil#kotlin.math%24ceil(kotlin.Double)/x) to an integer towards positive infinity. ``` fun ceil(x: Double): Double ``` ``` fun ceil(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <cos> Computes the cosine of the angle [x](cos#kotlin.math%24cos(kotlin.Double)/x) given in radians. ``` fun cos(x: Double): Double ``` ``` fun cos(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <cosh> Computes the hyperbolic cosine of the value [x](cosh#kotlin.math%24cosh(kotlin.Double)/x). ``` fun cosh(x: Double): Double ``` ``` fun cosh(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <exp> Computes Euler's number `e` raised to the power of the value [x](exp#kotlin.math%24exp(kotlin.Double)/x). ``` fun exp(x: Double): Double ``` ``` fun exp(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <expm1> Computes `exp(x) - 1`. ``` fun expm1(x: Double): Double ``` ``` fun expm1(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <floor> Rounds the given value [x](floor#kotlin.math%24floor(kotlin.Double)/x) to an integer towards negative infinity. ``` fun floor(x: Double): Double ``` ``` fun floor(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <hypot> Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow. ``` fun hypot(x: Double, y: Double): Double ``` ``` fun hypot(x: Float, y: Float): Float ``` **Platform and version requirements:** JVM (1.2), Native (1.2) #### [IEEErem](-i-e-e-erem) Computes the remainder of division of this value by the [divisor](-i-e-e-erem#kotlin.math%24IEEErem(kotlin.Double,%20kotlin.Double)/divisor) value according to the IEEE 754 standard. ``` fun Double.IEEErem(divisor: Double): Double ``` ``` fun Float.IEEErem(divisor: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <ln> Computes the natural logarithm (base `E`) of the value [x](ln#kotlin.math%24ln(kotlin.Double)/x). ``` fun ln(x: Double): Double ``` ``` fun ln(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <ln1p> Computes `ln(x + 1)`. ``` fun ln1p(x: Double): Double ``` ``` fun ln1p(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <log> Computes the logarithm of the value [x](log#kotlin.math%24log(kotlin.Double,%20kotlin.Double)/x) to the given [base](log#kotlin.math%24log(kotlin.Double,%20kotlin.Double)/base). ``` fun log(x: Double, base: Double): Double ``` ``` fun log(x: Float, base: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <log10> Computes the common logarithm (base 10) of the value [x](log10#kotlin.math%24log10(kotlin.Double)/x). ``` fun log10(x: Double): Double ``` ``` fun log10(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <log2> Computes the binary logarithm (base 2) of the value [x](log2#kotlin.math%24log2(kotlin.Double)/x). ``` fun log2(x: Double): Double ``` ``` fun log2(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <max> Returns the greater of two values. ``` fun max(a: UInt, b: UInt): UInt ``` ``` fun max(a: ULong, b: ULong): ULong ``` ``` fun max(a: Double, b: Double): Double ``` ``` fun max(a: Float, b: Float): Float ``` ``` fun max(a: Int, b: Int): Int ``` ``` fun max(a: Long, b: Long): Long ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <min> Returns the smaller of two values. ``` fun min(a: UInt, b: UInt): UInt ``` ``` fun min(a: ULong, b: ULong): ULong ``` ``` fun min(a: Double, b: Double): Double ``` ``` fun min(a: Float, b: Float): Float ``` ``` fun min(a: Int, b: Int): Int ``` ``` fun min(a: Long, b: Long): Long ``` #### [nextDown](next-down) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction of negative infinity. ``` fun Double.nextDown(): Double ``` **Platform and version requirements:** JVM (1.2), Native (1.2) Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction of negative infinity. ``` fun Float.nextDown(): Float ``` #### [nextTowards](next-towards) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction from this value towards the value [to](next-towards#kotlin.math%24nextTowards(kotlin.Double,%20kotlin.Double)/to). ``` fun Double.nextTowards(to: Double): Double ``` **Platform and version requirements:** JVM (1.2), Native (1.2) Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction from this value towards the value [to](next-towards#kotlin.math%24nextTowards(kotlin.Float,%20kotlin.Float)/to). ``` fun Float.nextTowards(to: Float): Float ``` #### [nextUp](next-up) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction of positive infinity. ``` fun Double.nextUp(): Double ``` **Platform and version requirements:** JVM (1.2), Native (1.2) Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction of positive infinity. ``` fun Float.nextUp(): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <pow> Raises this value to the power [x](pow#kotlin.math%24pow(kotlin.Double,%20kotlin.Double)/x). ``` fun Double.pow(x: Double): Double ``` ``` fun Float.pow(x: Float): Float ``` Raises this value to the integer power [n](pow#kotlin.math%24pow(kotlin.Double,%20kotlin.Int)/n). ``` fun Double.pow(n: Int): Double ``` ``` fun Float.pow(n: Int): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <round> Rounds the given value [x](round#kotlin.math%24round(kotlin.Double)/x) towards the closest integer with ties rounded towards even integer. ``` fun round(x: Double): Double ``` ``` fun round(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [roundToInt](round-to-int) Rounds this [Double](../kotlin/-double/index#kotlin.Double) value to the nearest integer and converts the result to [Int](../kotlin/-int/index#kotlin.Int). Ties are rounded towards positive infinity. ``` fun Double.roundToInt(): Int ``` Rounds this [Float](../kotlin/-float/index#kotlin.Float) value to the nearest integer and converts the result to [Int](../kotlin/-int/index#kotlin.Int). Ties are rounded towards positive infinity. ``` fun Float.roundToInt(): Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [roundToLong](round-to-long) Rounds this [Double](../kotlin/-double/index#kotlin.Double) value to the nearest integer and converts the result to [Long](../kotlin/-long/index#kotlin.Long). Ties are rounded towards positive infinity. ``` fun Double.roundToLong(): Long ``` Rounds this [Float](../kotlin/-float/index#kotlin.Float) value to the nearest integer and converts the result to [Long](../kotlin/-long/index#kotlin.Long). Ties are rounded towards positive infinity. ``` fun Float.roundToLong(): Long ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <sign> Returns the sign of the given value [x](sign#kotlin.math%24sign(kotlin.Double)/x): ``` fun sign(x: Double): Double ``` ``` fun sign(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <sin> Computes the sine of the angle [x](sin#kotlin.math%24sin(kotlin.Double)/x) given in radians. ``` fun sin(x: Double): Double ``` ``` fun sin(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <sinh> Computes the hyperbolic sine of the value [x](sinh#kotlin.math%24sinh(kotlin.Double)/x). ``` fun sinh(x: Double): Double ``` ``` fun sinh(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <sqrt> Computes the positive square root of the value [x](sqrt#kotlin.math%24sqrt(kotlin.Double)/x). ``` fun sqrt(x: Double): Double ``` ``` fun sqrt(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <tan> Computes the tangent of the angle [x](tan#kotlin.math%24tan(kotlin.Double)/x) given in radians. ``` fun tan(x: Double): Double ``` ``` fun tan(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <tanh> Computes the hyperbolic tangent of the value [x](tanh#kotlin.math%24tanh(kotlin.Double)/x). ``` fun tanh(x: Double): Double ``` ``` fun tanh(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <truncate> Rounds the given value [x](truncate#kotlin.math%24truncate(kotlin.Double)/x) to an integer towards zero. ``` fun truncate(x: Double): Double ``` ``` fun truncate(x: Float): Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [withSign](with-sign) Returns this value with the sign bit same as of the [sign](with-sign#kotlin.math%24withSign(kotlin.Double,%20kotlin.Double)/sign) value. ``` fun Double.withSign(sign: Double): Double ``` ``` fun Double.withSign(sign: Int): Double ``` ``` fun Float.withSign(sign: Float): Float ``` ``` fun Float.withSign(sign: Int): Float ```
programming_docs
kotlin round round ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <round> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun round(x: Double): Double ``` ``` fun round(x: Float): Float ``` Rounds the given value [x](round#kotlin.math%24round(kotlin.Double)/x) towards the closest integer with ties rounded towards even integer. Special cases: * `round(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. kotlin cos cos === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <cos> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun cos(x: Double): Double ``` ``` fun cos(x: Float): Float ``` Computes the cosine of the angle [x](cos#kotlin.math%24cos(kotlin.Double)/x) given in radians. Special cases: * `cos(NaN|+Inf|-Inf)` is `NaN` kotlin ln1p ln1p ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <ln1p> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun ln1p(x: Double): Double ``` ``` fun ln1p(x: Float): Float ``` Computes `ln(x + 1)`. This function can be implemented to produce more precise result for [x](ln1p#kotlin.math%24ln1p(kotlin.Double)/x) near zero. Special cases: * `ln1p(NaN)` is `NaN` * `ln1p(x)` is `NaN` where `x < -1.0` * `ln1p(-1.0)` is `-Inf` * `ln1p(+Inf)` is `+Inf` **See Also** [ln](ln#kotlin.math%24ln(kotlin.Double)) [expm1](expm1#kotlin.math%24expm1(kotlin.Double)) kotlin roundToInt roundToInt ========== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [roundToInt](round-to-int) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.roundToInt(): Int ``` Rounds this [Double](../kotlin/-double/index#kotlin.Double) value to the nearest integer and converts the result to [Int](../kotlin/-int/index#kotlin.Int). Ties are rounded towards positive infinity. Special cases: * `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE` * `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE` Exceptions ---------- `IllegalArgumentException` - when this value is `NaN` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Float.roundToInt(): Int ``` Rounds this [Float](../kotlin/-float/index#kotlin.Float) value to the nearest integer and converts the result to [Int](../kotlin/-int/index#kotlin.Int). Ties are rounded towards positive infinity. Special cases: * `x.roundToInt() == Int.MAX_VALUE` when `x > Int.MAX_VALUE` * `x.roundToInt() == Int.MIN_VALUE` when `x < Int.MIN_VALUE` Exceptions ---------- `IllegalArgumentException` - when this value is `NaN` kotlin sqrt sqrt ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <sqrt> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun sqrt(x: Double): Double ``` ``` fun sqrt(x: Float): Float ``` Computes the positive square root of the value [x](sqrt#kotlin.math%24sqrt(kotlin.Double)/x). Special cases: * `sqrt(x)` is `NaN` when `x < 0` or `x` is `NaN` kotlin sign sign ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <sign> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun sign(x: Double): Double ``` ``` fun sign(x: Float): Float ``` Returns the sign of the given value [x](sign#kotlin.math%24sign(kotlin.Double)/x): * `-1.0` if the value is negative, * zero if the value is zero, * `1.0` if the value is positive Special case: * `sign(NaN)` is `NaN` **Platform and version requirements:** Native (1.2) ``` val Double.sign: Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Double.sign: Double ``` **Platform and version requirements:** Native (1.2) ``` val Float.sign: Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Float.sign: Float ``` Returns the sign of this value: * `-1.0` if the value is negative, * zero if the value is zero, * `1.0` if the value is positive Special case: * `NaN.sign` is `NaN` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` val Int.sign: Int ``` ``` val Long.sign: Int ``` Returns the sign of this value: * `-1` if the value is negative, * `0` if the value is zero, * `1` if the value is positive kotlin tanh tanh ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <tanh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun tanh(x: Double): Double ``` ``` fun tanh(x: Float): Float ``` Computes the hyperbolic tangent of the value [x](tanh#kotlin.math%24tanh(kotlin.Double)/x). Special cases: * `tanh(NaN)` is `NaN` * `tanh(+Inf)` is `1.0` * `tanh(-Inf)` is `-1.0` kotlin cbrt cbrt ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <cbrt> **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) ``` fun cbrt(x: Double): Double ``` ``` fun cbrt(x: Float): Float ``` Returns the cube root of [x](cbrt#kotlin.math%24cbrt(kotlin.Double)/x). For any `x`, `cbrt(-x) == -cbrt(x)`; that is, the cube root of a negative value is the negative of the cube root of that value's magnitude. Special cases: Special cases: * If the argument is `NaN`, then the result is `NaN`. * If the argument is infinite, then the result is an infinity with the same sign as the argument. * If the argument is zero, then the result is a zero with the same sign as the argument. kotlin pow pow === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <pow> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.pow(x: Double): Double ``` ``` fun Float.pow(x: Float): Float ``` Raises this value to the power [x](pow#kotlin.math%24pow(kotlin.Double,%20kotlin.Double)/x). Special cases: * `b.pow(0.0)` is `1.0` * `b.pow(1.0) == b` * `b.pow(NaN)` is `NaN` * `NaN.pow(x)` is `NaN` for `x != 0.0` * `b.pow(Inf)` is `NaN` for `abs(b) == 1.0` * `b.pow(x)` is `NaN` for `b < 0` and `x` is finite and not an integer **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.pow(n: Int): Double ``` ``` fun Float.pow(n: Int): Float ``` Raises this value to the integer power [n](pow#kotlin.math%24pow(kotlin.Double,%20kotlin.Int)/n). See the other overload of [pow](pow#kotlin.math%24pow(kotlin.Double,%20kotlin.Double)) for details. kotlin exp exp === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <exp> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun exp(x: Double): Double ``` ``` fun exp(x: Float): Float ``` Computes Euler's number `e` raised to the power of the value [x](exp#kotlin.math%24exp(kotlin.Double)/x). Special cases: * `exp(NaN)` is `NaN` * `exp(+Inf)` is `+Inf` * `exp(-Inf)` is `0.0` kotlin IEEErem IEEErem ======= [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [IEEErem](-i-e-e-erem) **Platform and version requirements:** JVM (1.2), Native (1.2) ``` fun Double.IEEErem(divisor: Double): Double ``` ``` fun Float.IEEErem(divisor: Float): Float ``` Computes the remainder of division of this value by the [divisor](-i-e-e-erem#kotlin.math%24IEEErem(kotlin.Double,%20kotlin.Double)/divisor) value according to the IEEE 754 standard. The result is computed as `r = this - (q * divisor)` where `q` is the quotient of division rounded to the nearest integer, `q = round(this / other)`. Special cases: * `x.IEEErem(y)` is `NaN`, when `x` is `NaN` or `y` is `NaN` or `x` is `+Inf|-Inf` or `y` is zero. * `x.IEEErem(y) == x` when `x` is finite and `y` is infinite. **See Also** [round](round#kotlin.math%24round(kotlin.Double)) kotlin absoluteValue absoluteValue ============= [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [absoluteValue](absolute-value) **Platform and version requirements:** Native (1.2) ``` val Double.absoluteValue: Double ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Double.absoluteValue: Double ``` **Platform and version requirements:** Native (1.2) ``` val Float.absoluteValue: Float ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Float.absoluteValue: Float ``` Returns the absolute value of this value. Special cases: * `NaN.absoluteValue` is `NaN` **See Also** [abs](abs#kotlin.math%24abs(kotlin.Double)) **Platform and version requirements:** Native (1.2) ``` val Int.absoluteValue: Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Int.absoluteValue: Int ``` Returns the absolute value of this value. Special cases: * `Int.MIN_VALUE.absoluteValue` is `Int.MIN_VALUE` due to an overflow **See Also** [abs](abs#kotlin.math%24abs(kotlin.Double)) **Platform and version requirements:** Native (1.2) ``` val Long.absoluteValue: Long ``` **Platform and version requirements:** JVM (1.2), JS (1.2) ``` inline val Long.absoluteValue: Long ``` Returns the absolute value of this value. Special cases: * `Long.MIN_VALUE.absoluteValue` is `Long.MIN_VALUE` due to an overflow **See Also** [abs](abs#kotlin.math%24abs(kotlin.Double)) kotlin nextDown nextDown ======== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [nextDown](next-down) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.nextDown(): Double ``` Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction of negative infinity. **Platform and version requirements:** JVM (1.2), Native (1.2) ``` fun Float.nextDown(): Float ``` Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction of negative infinity. kotlin ceil ceil ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <ceil> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun ceil(x: Double): Double ``` Rounds the given value [x](ceil#kotlin.math%24ceil(kotlin.Double)/x) to an integer towards positive infinity. **Return** the smallest double value that is greater than or equal to the given value [x](ceil#kotlin.math%24ceil(kotlin.Double)/x) and is a mathematical integer. Special cases: * `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun ceil(x: Float): Float ``` Rounds the given value [x](ceil#kotlin.math%24ceil(kotlin.Float)/x) to an integer towards positive infinity. **Return** the smallest Float value that is greater than or equal to the given value [x](ceil#kotlin.math%24ceil(kotlin.Float)/x) and is a mathematical integer. Special cases: * `ceil(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. kotlin hypot hypot ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <hypot> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun hypot(x: Double, y: Double): Double ``` ``` fun hypot(x: Float, y: Float): Float ``` Computes `sqrt(x^2 + y^2)` without intermediate overflow or underflow. Special cases: * returns `+Inf` if any of arguments is infinite * returns `NaN` if any of arguments is `NaN` and the other is not infinite kotlin sinh sinh ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <sinh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun sinh(x: Double): Double ``` ``` fun sinh(x: Float): Float ``` Computes the hyperbolic sine of the value [x](sinh#kotlin.math%24sinh(kotlin.Double)/x). Special cases: * `sinh(NaN)` is `NaN` * `sinh(+Inf)` is `+Inf` * `sinh(-Inf)` is `-Inf` kotlin max max === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <max> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun max(a: Double, b: Double): Double ``` ``` fun max(a: Float, b: Float): Float ``` Returns the greater of two values. If either value is `NaN`, then the result is `NaN`. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun max(a: Int, b: Int): Int ``` ``` fun max(a: Long, b: Long): Long ``` Returns the greater of two values. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun max(a: UInt, b: UInt): UInt ``` ``` fun max(a: ULong, b: ULong): ULong ``` Returns the greater of two values. kotlin acosh acosh ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <acosh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun acosh(x: Double): Double ``` ``` fun acosh(x: Float): Float ``` Computes the inverse hyperbolic cosine of the value [x](acosh#kotlin.math%24acosh(kotlin.Double)/x). The returned value is positive `y` such that `cosh(y) == x`. Special cases: * `acosh(NaN)` is `NaN` * `acosh(x)` is `NaN` when `x < 1` * `acosh(+Inf)` is `+Inf` kotlin min min === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <min> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun min(a: Double, b: Double): Double ``` ``` fun min(a: Float, b: Float): Float ``` Returns the smaller of two values. If either value is `NaN`, then the result is `NaN`. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun min(a: Int, b: Int): Int ``` ``` fun min(a: Long, b: Long): Long ``` Returns the smaller of two values. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun min(a: UInt, b: UInt): UInt ``` ``` fun min(a: ULong, b: ULong): ULong ``` Returns the smaller of two values. kotlin log log === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <log> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun log(x: Double, base: Double): Double ``` ``` fun log(x: Float, base: Float): Float ``` Computes the logarithm of the value [x](log#kotlin.math%24log(kotlin.Double,%20kotlin.Double)/x) to the given [base](log#kotlin.math%24log(kotlin.Double,%20kotlin.Double)/base). Special cases: * `log(x, b)` is `NaN` if either `x` or `b` are `NaN` * `log(x, b)` is `NaN` when `x < 0` or `b <= 0` or `b == 1.0` * `log(+Inf, +Inf)` is `NaN` * `log(+Inf, b)` is `+Inf` for `b > 1` and `-Inf` for `b < 1` * `log(0.0, b)` is `-Inf` for `b > 1` and `+Inf` for `b > 1` See also logarithm functions for common fixed bases: [ln](ln#kotlin.math%24ln(kotlin.Double)), [log10](log10#kotlin.math%24log10(kotlin.Double)) and [log2](log2#kotlin.math%24log2(kotlin.Double)). kotlin expm1 expm1 ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <expm1> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun expm1(x: Double): Double ``` ``` fun expm1(x: Float): Float ``` Computes `exp(x) - 1`. This function can be implemented to produce more precise result for [x](expm1#kotlin.math%24expm1(kotlin.Double)/x) near zero. Special cases: * `expm1(NaN)` is `NaN` * `expm1(+Inf)` is `+Inf` * `expm1(-Inf)` is `-1.0` **See Also** [exp](exp#kotlin.math%24exp(kotlin.Double)) kotlin abs abs === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <abs> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun abs(x: Double): Double ``` ``` fun abs(x: Float): Float ``` Returns the absolute value of the given value [x](abs#kotlin.math%24abs(kotlin.Double)/x). Special cases: * `abs(NaN)` is `NaN` **See Also** absoluteValue **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun abs(n: Int): Int ``` Returns the absolute value of the given value [n](abs#kotlin.math%24abs(kotlin.Int)/n). Special cases: * `abs(Int.MIN_VALUE)` is `Int.MIN_VALUE` due to an overflow **See Also** absoluteValue **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun abs(n: Long): Long ``` Returns the absolute value of the given value [n](abs#kotlin.math%24abs(kotlin.Long)/n). Special cases: * `abs(Long.MIN_VALUE)` is `Long.MIN_VALUE` due to an overflow **See Also** absoluteValue kotlin ulp ulp === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <ulp> **Platform and version requirements:** JS (1.2), Native (1.2) ``` val Double.ulp: Double ``` **Platform and version requirements:** JVM (1.2) ``` inline val Double.ulp: Double ``` Returns the ulp (unit in the last place) of this value. An ulp is a positive distance between this value and the next nearest [Double](../kotlin/-double/index#kotlin.Double) value larger in magnitude. Special Cases: * `NaN.ulp` is `NaN` * `x.ulp` is `+Inf` when `x` is `+Inf` or `-Inf` * `0.0.ulp` is `Double.MIN_VALUE` **Platform and version requirements:** JVM (1.2) ``` inline val Float.ulp: Float ``` **Platform and version requirements:** Native (1.2) ``` val Float.ulp: Float ``` Returns the ulp of this value. An ulp is a positive distance between this value and the next nearest [Float](../kotlin/-float/index#kotlin.Float) value larger in magnitude. Special Cases: * `NaN.ulp` is `NaN` * `x.ulp` is `+Inf` when `x` is `+Inf` or `-Inf` * `0.0.ulp` is `Float.MIN_VALUE` kotlin nextUp nextUp ====== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [nextUp](next-up) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.nextUp(): Double ``` Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction of positive infinity. **Platform and version requirements:** JVM (1.2), Native (1.2) ``` fun Float.nextUp(): Float ``` Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction of positive infinity. kotlin log10 log10 ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <log10> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun log10(x: Double): Double ``` ``` fun log10(x: Float): Float ``` Computes the common logarithm (base 10) of the value [x](log10#kotlin.math%24log10(kotlin.Double)/x). **See Also** [ln](ln#kotlin.math%24ln(kotlin.Double)) kotlin nextTowards nextTowards =========== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [nextTowards](next-towards) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.nextTowards(to: Double): Double ``` Returns the [Double](../kotlin/-double/index#kotlin.Double) value nearest to this value in direction from this value towards the value [to](next-towards#kotlin.math%24nextTowards(kotlin.Double,%20kotlin.Double)/to). Special cases: * `x.nextTowards(y)` is `NaN` if either `x` or `y` are `NaN` * `x.nextTowards(x) == x` **Platform and version requirements:** JVM (1.2), Native (1.2) ``` fun Float.nextTowards(to: Float): Float ``` Returns the [Float](../kotlin/-float/index#kotlin.Float) value nearest to this value in direction from this value towards the value [to](next-towards#kotlin.math%24nextTowards(kotlin.Float,%20kotlin.Float)/to). Special cases: * `x.nextTowards(y)` is `NaN` if either `x` or `y` are `NaN` * `x.nextTowards(x) == x` kotlin PI PI == [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [PI](-p-i) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` const val PI: Double ``` Ratio of the circumference of a circle to its diameter, approximately 3.14159.
programming_docs
kotlin truncate truncate ======== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <truncate> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun truncate(x: Double): Double ``` ``` fun truncate(x: Float): Float ``` Rounds the given value [x](truncate#kotlin.math%24truncate(kotlin.Double)/x) to an integer towards zero. **Return** the value [x](truncate#kotlin.math%24truncate(kotlin.Double)/x) having its fractional part truncated. Special cases: * `truncate(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. kotlin atan2 atan2 ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <atan2> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun atan2(y: Double, x: Double): Double ``` ``` fun atan2(y: Float, x: Float): Float ``` Returns the angle `theta` of the polar coordinates `(r, theta)` that correspond to the rectangular coordinates `(x, y)` by computing the arc tangent of the value [y](atan2#kotlin.math%24atan2(kotlin.Double,%20kotlin.Double)/y) / [x](atan2#kotlin.math%24atan2(kotlin.Double,%20kotlin.Double)/x); the returned value is an angle in the range from `-PI` to `PI` radians. Special cases: * `atan2(0.0, 0.0)` is `0.0` * `atan2(0.0, x)` is `0.0` for `x > 0` and `PI` for `x < 0` * `atan2(-0.0, x)` is `-0.0` for 'x > 0 `and` -PI `for` x < 0` * `atan2(y, +Inf)` is `0.0` for `0 < y < +Inf` and `-0.0` for '-Inf < y < 0` * `atan2(y, -Inf)` is `PI` for `0 < y < +Inf` and `-PI` for `-Inf < y < 0` * `atan2(y, 0.0)` is `PI/2` for `y > 0` and `-PI/2` for `y < 0` * `atan2(+Inf, x)` is `PI/2` for finite `x`y * `atan2(-Inf, x)` is `-PI/2` for finite `x` * `atan2(NaN, x)` and `atan2(y, NaN)` is `NaN` kotlin acos acos ==== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <acos> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun acos(x: Double): Double ``` ``` fun acos(x: Float): Float ``` Computes the arc cosine of the value [x](acos#kotlin.math%24acos(kotlin.Double)/x); the returned value is an angle in the range from `0.0` to `PI` radians. Special cases: - `acos(x)` is `NaN`, when `abs(x) > 1` or x is `NaN` kotlin floor floor ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <floor> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun floor(x: Double): Double ``` Rounds the given value [x](floor#kotlin.math%24floor(kotlin.Double)/x) to an integer towards negative infinity. **Return** the largest double value that is smaller than or equal to the given value [x](floor#kotlin.math%24floor(kotlin.Double)/x) and is a mathematical integer. Special cases: * `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun floor(x: Float): Float ``` Rounds the given value [x](floor#kotlin.math%24floor(kotlin.Float)/x) to an integer towards negative infinity. **Return** the largest Float value that is smaller than or equal to the given value [x](floor#kotlin.math%24floor(kotlin.Float)/x) and is a mathematical integer. Special cases: * `floor(x)` is `x` where `x` is `NaN` or `+Inf` or `-Inf` or already a mathematical integer. kotlin withSign withSign ======== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [withSign](with-sign) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.withSign(sign: Double): Double ``` ``` fun Float.withSign(sign: Float): Float ``` Returns this value with the sign bit same as of the [sign](with-sign#kotlin.math%24withSign(kotlin.Double,%20kotlin.Double)/sign) value. If [sign](with-sign#kotlin.math%24withSign(kotlin.Double,%20kotlin.Double)/sign) is `NaN` the sign of the result is undefined. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.withSign(sign: Int): Double ``` ``` fun Float.withSign(sign: Int): Float ``` Returns this value with the sign bit same as of the [sign](with-sign#kotlin.math%24withSign(kotlin.Double,%20kotlin.Int)/sign) value. kotlin roundToLong roundToLong =========== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / [roundToLong](round-to-long) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.roundToLong(): Long ``` Rounds this [Double](../kotlin/-double/index#kotlin.Double) value to the nearest integer and converts the result to [Long](../kotlin/-long/index#kotlin.Long). Ties are rounded towards positive infinity. Special cases: * `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE` * `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE` Exceptions ---------- `IllegalArgumentException` - when this value is `NaN` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Float.roundToLong(): Long ``` Rounds this [Float](../kotlin/-float/index#kotlin.Float) value to the nearest integer and converts the result to [Long](../kotlin/-long/index#kotlin.Long). Ties are rounded towards positive infinity. Special cases: * `x.roundToLong() == Long.MAX_VALUE` when `x > Long.MAX_VALUE` * `x.roundToLong() == Long.MIN_VALUE` when `x < Long.MIN_VALUE` Exceptions ---------- `IllegalArgumentException` - when this value is `NaN` kotlin atanh atanh ===== [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <atanh> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun atanh(x: Double): Double ``` ``` fun atanh(x: Float): Float ``` Computes the inverse hyperbolic tangent of the value [x](atanh#kotlin.math%24atanh(kotlin.Double)/x). The returned value is `y` such that `tanh(y) == x`. Special cases: * `tanh(NaN)` is `NaN` * `tanh(x)` is `NaN` when `x > 1` or `x < -1` * `tanh(1.0)` is `+Inf` * `tanh(-1.0)` is `-Inf` kotlin sin sin === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <sin> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun sin(x: Double): Double ``` ``` fun sin(x: Float): Float ``` Computes the sine of the angle [x](sin#kotlin.math%24sin(kotlin.Double)/x) given in radians. Special cases: * `sin(NaN|+Inf|-Inf)` is `NaN` kotlin tan tan === [kotlin-stdlib](../../../../../index) / [kotlin.math](index) / <tan> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun tan(x: Double): Double ``` ``` fun tan(x: Float): Float ``` Computes the tangent of the angle [x](tan#kotlin.math%24tan(kotlin.Double)/x) given in radians. Special cases: * `tan(NaN|+Inf|-Inf)` is `NaN` kotlin setUIntAt setUIntAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setUIntAt](set-u-int-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setUIntAt(index: Int, value: UInt) ``` Sets UInt out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-int-at#kotlin.native%24setUIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UInt)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-u-int-at#kotlin.native%24setUIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UInt)/index) is outside of array boundaries. kotlin getULongAt getULongAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getULongAt](get-u-long-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.getULongAt(     index: Int ): ULong ``` Gets ULong out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-long-at#kotlin.native%24getULongAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-u-long-at#kotlin.native%24getULongAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin getUShortAt getUShortAt =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getUShortAt](get-u-short-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.getUShortAt(     index: Int ): UShort ``` Gets UShort out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-short-at#kotlin.native%24getUShortAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-u-short-at#kotlin.native%24getUShortAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin setULongAt setULongAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setULongAt](set-u-long-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.setULongAt(     index: Int,     value: ULong) ``` Sets ULong out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-long-at#kotlin.native%24setULongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.ULong)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-u-long-at#kotlin.native%24setULongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.ULong)/index) is outside of array boundaries. kotlin getFloatAt getFloatAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getFloatAt](get-float-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getFloatAt(index: Int): Float ``` Gets [Float](../kotlin/-float/index#kotlin.Float) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-float-at#kotlin.native%24getFloatAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-float-at#kotlin.native%24getFloatAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin deinitRuntimeIfNeeded deinitRuntimeIfNeeded ===================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [deinitRuntimeIfNeeded](deinit-runtime-if-needed) **Platform and version requirements:** Native (1.3) ``` fun deinitRuntimeIfNeeded() ``` **Deprecated:** Deinit runtime can not be called from Kotlin Deinitializes Kotlin runtime for the current thread, if was inited. Cannot be called from Kotlin frames holding references, thus deprecated. kotlin getIntAt getIntAt ======== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getIntAt](get-int-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getIntAt(index: Int): Int ``` Gets [Int](../kotlin/-int/index#kotlin.Int) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-int-at#kotlin.native%24getIntAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-int-at#kotlin.native%24getIntAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin getDoubleAt getDoubleAt =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getDoubleAt](get-double-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getDoubleAt(index: Int): Double ``` Gets [Double](../kotlin/-double/index#kotlin.Double) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-double-at#kotlin.native%24getDoubleAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-double-at#kotlin.native%24getDoubleAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin Package kotlin.native Package kotlin.native ===================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) Types ----- **Platform and version requirements:** Native (1.3) #### [BitSet](-bit-set/index) A vector of bits growing if necessary and allowing one to set/clear/read bits from it by a bit index. ``` class BitSet ``` **Platform and version requirements:** Native (1.3) #### [CpuArchitecture](-cpu-architecture/index) Central Processor Unit architecture. ``` enum class CpuArchitecture ``` **Platform and version requirements:** Native (1.3) #### [FileFailedToInitializeException](-file-failed-to-initialize-exception/index) Exception thrown when there was an error during file initalization. ``` class FileFailedToInitializeException : RuntimeException ``` **Platform and version requirements:** Native (1.3) #### [ImmutableBlob](-immutable-blob/index) An immutable compile-time array of bytes. ``` class ImmutableBlob ``` **Platform and version requirements:** Native (1.3) #### [IncorrectDereferenceException](-incorrect-dereference-exception/index) Exception thrown when top level variable is accessed from incorrect execution context. ``` class IncorrectDereferenceException : RuntimeException ``` **Platform and version requirements:** Native (1.3) #### [MemoryModel](-memory-model/index) Memory model. ``` enum class MemoryModel ``` **Platform and version requirements:** Native (1.3) #### [OsFamily](-os-family/index) Operating system family. ``` enum class OsFamily ``` **Platform and version requirements:** Native (1.3) #### [Platform](-platform/index) Object describing the current platform program executes upon. ``` object Platform ``` **Platform and version requirements:** Native (1.3) #### [ReportUnhandledExceptionHook](-report-unhandled-exception-hook) Typealias describing custom exception reporting hook. ``` typealias ReportUnhandledExceptionHook = (Throwable) -> Unit ``` **Platform and version requirements:** Native (1.3) #### [Vector128](-vector128/index) ``` class Vector128 ``` Annotations ----------- **Platform and version requirements:** Native (1.3) #### [CName](-c-name/index) Makes top level function available from C/C++ code with the given name. ``` annotation class CName ``` **Platform and version requirements:** Native (1.3) #### [EagerInitialization](-eager-initialization/index) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". ``` annotation class EagerInitialization ``` **Platform and version requirements:** #### [FreezingIsDeprecated](-freezing-is-deprecated) Freezing API is deprecated since 1.7.20. ``` annotation class FreezingIsDeprecated ``` **Platform and version requirements:** Native (1.0) #### [HiddenFromObjC](-hidden-from-obj-c/index) Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. ``` annotation class HiddenFromObjC ``` **Platform and version requirements:** Native (1.0) #### [HidesFromObjC](-hides-from-obj-c/index) Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. ``` annotation class HidesFromObjC ``` **Platform and version requirements:** Native (1.0) #### [ObjCName](-obj-c-name/index) Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. ``` annotation class ObjCName ``` **Platform and version requirements:** Native (1.0) #### [RefinesInSwift](-refines-in-swift/index) Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. ``` annotation class RefinesInSwift ``` **Platform and version requirements:** Native (1.3) #### [Retain](-retain/index) Preserve the function entry point during global optimizations. ``` annotation class Retain ``` **Platform and version requirements:** Native (1.3) #### [RetainForTarget](-retain-for-target/index) Preserve the function entry point during global optimizations, only for the given target. ``` annotation class RetainForTarget ``` **Platform and version requirements:** Native (1.0) #### [ShouldRefineInSwift](-should-refine-in-swift/index) Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. ``` annotation class ShouldRefineInSwift ``` **Platform and version requirements:** Native (1.3) #### [SymbolName](-symbol-name/index) This is a dangerous deprecated and internal annotation. Please avoid using it. ``` annotation class SymbolName ``` Functions --------- **Platform and version requirements:** Native (1.3) #### [asCPointer](as-c-pointer) Returns stable C pointer to data at certain [offset](as-c-pointer#kotlin.native%24asCPointer(kotlin.native.ImmutableBlob,%20kotlin.Int)/offset), useful as a way to pass resource to C APIs. ``` fun ImmutableBlob.asCPointer(     offset: Int = 0 ): CPointer<ByteVar> ``` **Platform and version requirements:** Native (1.3) #### [asUCPointer](as-u-c-pointer) ``` fun ImmutableBlob.asUCPointer(     offset: Int = 0 ): CPointer<UByteVar> ``` **Platform and version requirements:** Native (1.3) #### [deinitRuntimeIfNeeded](deinit-runtime-if-needed) Deinitializes Kotlin runtime for the current thread, if was inited. Cannot be called from Kotlin frames holding references, thus deprecated. ``` fun deinitRuntimeIfNeeded() ``` **Platform and version requirements:** Native (1.3) #### [getCharAt](get-char-at) Gets [Char](../kotlin/-char/index#kotlin.Char) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-char-at#kotlin.native%24getCharAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getCharAt(index: Int): Char ``` **Platform and version requirements:** Native (1.3) #### [getDoubleAt](get-double-at) Gets [Double](../kotlin/-double/index#kotlin.Double) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-double-at#kotlin.native%24getDoubleAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getDoubleAt(index: Int): Double ``` **Platform and version requirements:** Native (1.3) #### [getFloatAt](get-float-at) Gets [Float](../kotlin/-float/index#kotlin.Float) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-float-at#kotlin.native%24getFloatAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getFloatAt(index: Int): Float ``` **Platform and version requirements:** Native (1.3) #### [getIntAt](get-int-at) Gets [Int](../kotlin/-int/index#kotlin.Int) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-int-at#kotlin.native%24getIntAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getIntAt(index: Int): Int ``` **Platform and version requirements:** Native (1.3) #### [getLongAt](get-long-at) Gets [Long](../kotlin/-long/index#kotlin.Long) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-long-at#kotlin.native%24getLongAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getLongAt(index: Int): Long ``` **Platform and version requirements:** Native (1.3) #### [getShortAt](get-short-at) Gets [Short](../kotlin/-short/index#kotlin.Short) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-short-at#kotlin.native%24getShortAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getShortAt(index: Int): Short ``` **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](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:** Native (1.3) #### [getUByteAt](get-u-byte-at) Gets UByte out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-byte-at#kotlin.native%24getUByteAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUByteAt(index: Int): UByte ``` **Platform and version requirements:** Native (1.3) #### [getUIntAt](get-u-int-at) Gets UInt out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-int-at#kotlin.native%24getUIntAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUIntAt(index: Int): UInt ``` **Platform and version requirements:** Native (1.3) #### [getULongAt](get-u-long-at) Gets ULong out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-long-at#kotlin.native%24getULongAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getULongAt(index: Int): ULong ``` **Platform and version requirements:** Native (1.6) #### [getUnhandledExceptionHook](get-unhandled-exception-hook) Returns a user-defined unhandled exception hook set by [setUnhandledExceptionHook](set-unhandled-exception-hook) or `null` if no user-defined hooks were set. ``` fun getUnhandledExceptionHook(): ReportUnhandledExceptionHook? ``` **Platform and version requirements:** Native (1.3) #### [getUShortAt](get-u-short-at) Gets UShort out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-short-at#kotlin.native%24getUShortAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUShortAt(index: Int): UShort ``` **Platform and version requirements:** Native (1.3) #### [identityHashCode](identity-hash-code) Compute stable wrt potential object relocations by the memory manager identity hash code. ``` fun Any?.identityHashCode(): Int ``` **Platform and version requirements:** Native (1.3) #### [immutableBlobOf](immutable-blob-of) Creates [ImmutableBlob](-immutable-blob/index) out of compile-time constant data. ``` fun immutableBlobOf(vararg elements: Short): ImmutableBlob ``` **Platform and version requirements:** Native (1.3) #### [initRuntimeIfNeeded](init-runtime-if-needed) Initializes Kotlin runtime for the current thread, if not inited already. ``` fun initRuntimeIfNeeded() ``` **Platform and version requirements:** Native (1.3) #### [isExperimentalMM](is-experimental-m-m) ``` fun isExperimentalMM(): Boolean ``` **Platform and version requirements:** Native (1.6) #### [processUnhandledException](process-unhandled-exception) Performs the default processing of unhandled exception. ``` fun processUnhandledException(throwable: Throwable) ``` **Platform and version requirements:** Native (1.3) #### [setCharAt](set-char-at) Sets [Char](../kotlin/-char/index#kotlin.Char) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-char-at#kotlin.native%24setCharAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Char)/index) ``` fun ByteArray.setCharAt(index: Int, value: Char) ``` **Platform and version requirements:** Native (1.3) #### [setDoubleAt](set-double-at) Sets [Double](../kotlin/-double/index#kotlin.Double) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-double-at#kotlin.native%24setDoubleAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Double)/index) ``` fun ByteArray.setDoubleAt(index: Int, value: Double) ``` **Platform and version requirements:** Native (1.3) #### [setFloatAt](set-float-at) Sets [Float](../kotlin/-float/index#kotlin.Float) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-float-at#kotlin.native%24setFloatAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Float)/index) ``` fun ByteArray.setFloatAt(index: Int, value: Float) ``` **Platform and version requirements:** Native (1.3) #### [setIntAt](set-int-at) Sets [Int](../kotlin/-int/index#kotlin.Int) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-int-at#kotlin.native%24setIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/index) ``` fun ByteArray.setIntAt(index: Int, value: Int) ``` **Platform and version requirements:** Native (1.3) #### [setLongAt](set-long-at) Sets [Long](../kotlin/-long/index#kotlin.Long) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-long-at#kotlin.native%24setLongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Long)/index) ``` fun ByteArray.setLongAt(index: Int, value: Long) ``` **Platform and version requirements:** Native (1.3) #### [setShortAt](set-short-at) Sets [Short](../kotlin/-short/index#kotlin.Short) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-short-at#kotlin.native%24setShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Short)/index) ``` fun ByteArray.setShortAt(index: Int, value: Short) ``` **Platform and version requirements:** Native (1.3) #### [setUByteAt](set-u-byte-at) Sets UByte out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-byte-at#kotlin.native%24setUByteAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UByte)/index) ``` fun ByteArray.setUByteAt(index: Int, value: UByte) ``` **Platform and version requirements:** Native (1.3) #### [setUIntAt](set-u-int-at) Sets UInt out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-int-at#kotlin.native%24setUIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UInt)/index) ``` fun ByteArray.setUIntAt(index: Int, value: UInt) ``` **Platform and version requirements:** Native (1.3) #### [setULongAt](set-u-long-at) Sets ULong out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-long-at#kotlin.native%24setULongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.ULong)/index) ``` fun ByteArray.setULongAt(index: Int, value: ULong) ``` **Platform and version requirements:** Native (1.3) #### [setUnhandledExceptionHook](set-unhandled-exception-hook) Installs an unhandled exception hook and returns an old hook, or `null` if no user-defined hooks were previously set. ``` fun setUnhandledExceptionHook(     hook: ReportUnhandledExceptionHook? ): ReportUnhandledExceptionHook? ``` ``` fun setUnhandledExceptionHook(     hook: ReportUnhandledExceptionHook ): ReportUnhandledExceptionHook? ``` **Platform and version requirements:** Native (1.3) #### [setUShortAt](set-u-short-at) Sets UShort out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-short-at#kotlin.native%24setUShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UShort)/index) ``` fun ByteArray.setUShortAt(index: Int, value: UShort) ``` **Platform and version requirements:** Native (1.6) #### [terminateWithUnhandledException](terminate-with-unhandled-exception) ``` fun terminateWithUnhandledException(     throwable: Throwable ): Nothing ``` **Platform and version requirements:** Native (1.3) #### [toByteArray](to-byte-array) Copies the data from this blob into a new [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray). ``` fun ImmutableBlob.toByteArray(     startIndex: Int = 0,     endIndex: Int = size ): ByteArray ``` **Platform and version requirements:** Native (1.3) #### [toUByteArray](to-u-byte-array) Copies the data from this blob into a new UByteArray. ``` fun ImmutableBlob.toUByteArray(     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` **Platform and version requirements:** Native (1.3) #### [vectorOf](vector-of) ``` fun vectorOf(     f0: Float,     f1: Float,     f2: Float,     f3: Float ): Vector128 ``` ``` fun vectorOf(f0: Int, f1: Int, f2: Int, f3: Int): Vector128 ```
programming_docs
kotlin setDoubleAt setDoubleAt =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setDoubleAt](set-double-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setDoubleAt(index: Int, value: Double) ``` Sets [Double](../kotlin/-double/index#kotlin.Double) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-double-at#kotlin.native%24setDoubleAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Double)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-double-at#kotlin.native%24setDoubleAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Double)/index) is outside of array boundaries. kotlin vectorOf vectorOf ======== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [vectorOf](vector-of) **Platform and version requirements:** Native (1.3) ``` fun vectorOf(     f0: Float,     f1: Float,     f2: Float,     f3: Float ): Vector128 ``` ``` fun vectorOf(f0: Int, f1: Int, f2: Int, f3: Int): Vector128 ``` kotlin getUnhandledExceptionHook getUnhandledExceptionHook ========================= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getUnhandledExceptionHook](get-unhandled-exception-hook) **Platform and version requirements:** Native (1.6) ``` @ExperimentalStdlibApi fun getUnhandledExceptionHook(): ReportUnhandledExceptionHook? ``` Returns a user-defined unhandled exception hook set by [setUnhandledExceptionHook](set-unhandled-exception-hook) or `null` if no user-defined hooks were set. kotlin getCharAt getCharAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getCharAt](get-char-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getCharAt(index: Int): Char ``` Gets [Char](../kotlin/-char/index#kotlin.Char) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-char-at#kotlin.native%24getCharAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-char-at#kotlin.native%24getCharAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin processUnhandledException processUnhandledException ========================= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [processUnhandledException](process-unhandled-exception) **Platform and version requirements:** Native (1.6) ``` @ExperimentalStdlibApi fun processUnhandledException(     throwable: Throwable) ``` Performs the default processing of unhandled exception. If user-defined hook set by [setUnhandledExceptionHook](set-unhandled-exception-hook) is present, calls it and returns. If the hook is not present, calls [terminateWithUnhandledException](terminate-with-unhandled-exception) with [throwable](process-unhandled-exception#kotlin.native%24processUnhandledException(kotlin.Throwable)/throwable). If the hook fails with exception, calls [terminateWithUnhandledException](terminate-with-unhandled-exception) with exception from the hook. kotlin setLongAt setLongAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setLongAt](set-long-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setLongAt(index: Int, value: Long) ``` Sets [Long](../kotlin/-long/index#kotlin.Long) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-long-at#kotlin.native%24setLongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Long)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-long-at#kotlin.native%24setLongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Long)/index) is outside of array boundaries. kotlin FreezingIsDeprecated FreezingIsDeprecated ==================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [FreezingIsDeprecated](-freezing-is-deprecated) **Platform and version requirements:** ``` @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 FreezingIsDeprecated ``` Freezing API is deprecated since 1.7.20. See [documentation](../../../../../docs/native-migration-guide) for details kotlin getUIntAt getUIntAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getUIntAt](get-u-int-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.getUIntAt(     index: Int ): UInt ``` Gets UInt out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-int-at#kotlin.native%24getUIntAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-u-int-at#kotlin.native%24getUIntAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin immutableBlobOf immutableBlobOf =============== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [immutableBlobOf](immutable-blob-of) **Platform and version requirements:** Native (1.3) ``` fun immutableBlobOf(vararg elements: Short): ImmutableBlob ``` Creates [ImmutableBlob](-immutable-blob/index) out of compile-time constant data. This method accepts values of [Short](../kotlin/-short/index#kotlin.Short) type in range `0x00..0xff`, other values are prohibited. One element still represent one byte in the output data. This is the only way to create ImmutableBlob for now. kotlin setFloatAt setFloatAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setFloatAt](set-float-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setFloatAt(index: Int, value: Float) ``` Sets [Float](../kotlin/-float/index#kotlin.Float) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-float-at#kotlin.native%24setFloatAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Float)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-float-at#kotlin.native%24setFloatAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Float)/index) is outside of array boundaries. kotlin identityHashCode identityHashCode ================ [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [identityHashCode](identity-hash-code) **Platform and version requirements:** Native (1.3) ``` fun Any?.identityHashCode(): Int ``` Compute stable wrt potential object relocations by the memory manager identity hash code. **Return** 0 for `null` object, identity hash code otherwise. kotlin toByteArray toByteArray =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [toByteArray](to-byte-array) **Platform and version requirements:** Native (1.3) ``` fun ImmutableBlob.toByteArray(     startIndex: Int = 0,     endIndex: Int = size ): ByteArray ``` Copies the data from this blob into a new [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray). Parameters ---------- `startIndex` - the beginning (inclusive) of the subrange to copy, 0 by default. `endIndex` - the end (exclusive) of the subrange to copy, size of this blob by default. kotlin getStackTraceAddresses getStackTraceAddresses ====================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getStackTraceAddresses](get-stack-trace-addresses) **Platform and version requirements:** Native (1.3) ``` fun Throwable.getStackTraceAddresses(): List<Long> ``` Returns a list of stack trace addresses representing the stack trace pertaining to this throwable. kotlin setUShortAt setUShortAt =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setUShortAt](set-u-short-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.setUShortAt(     index: Int,     value: UShort) ``` Sets UShort out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-short-at#kotlin.native%24setUShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UShort)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-u-short-at#kotlin.native%24setUShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UShort)/index) is outside of array boundaries. kotlin asCPointer asCPointer ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [asCPointer](as-c-pointer) **Platform and version requirements:** Native (1.3) ``` fun ImmutableBlob.asCPointer(     offset: Int = 0 ): CPointer<ByteVar> ``` Returns stable C pointer to data at certain [offset](as-c-pointer#kotlin.native%24asCPointer(kotlin.native.ImmutableBlob,%20kotlin.Int)/offset), useful as a way to pass resource to C APIs. **See Also** [kotlinx.cinterop.CPointer](../kotlinx.cinterop/-c-pointer/index) kotlin getUByteAt getUByteAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getUByteAt](get-u-byte-at) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ByteArray.getUByteAt(     index: Int ): UByte ``` Gets UByte out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-u-byte-at#kotlin.native%24getUByteAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-u-byte-at#kotlin.native%24getUByteAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin toUByteArray toUByteArray ============ [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [toUByteArray](to-u-byte-array) **Platform and version requirements:** Native (1.3) ``` @ExperimentalUnsignedTypes fun ImmutableBlob.toUByteArray(     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` Copies the data from this blob into a new UByteArray. Parameters ---------- `startIndex` - the beginning (inclusive) of the subrange to copy, 0 by default. `endIndex` - the end (exclusive) of the subrange to copy, size of this blob by default. kotlin setUByteAt setUByteAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setUByteAt](set-u-byte-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setUByteAt(index: Int, value: UByte) ``` Sets UByte out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-u-byte-at#kotlin.native%24setUByteAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UByte)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-u-byte-at#kotlin.native%24setUByteAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UByte)/index) is outside of array boundaries. kotlin terminateWithUnhandledException terminateWithUnhandledException =============================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [terminateWithUnhandledException](terminate-with-unhandled-exception) **Platform and version requirements:** Native (1.6) ``` @ExperimentalStdlibApi fun terminateWithUnhandledException(     throwable: Throwable ): Nothing ``` kotlin getLongAt getLongAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getLongAt](get-long-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getLongAt(index: Int): Long ``` Gets [Long](../kotlin/-long/index#kotlin.Long) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-long-at#kotlin.native%24getLongAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-long-at#kotlin.native%24getLongAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin setCharAt setCharAt ========= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setCharAt](set-char-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setCharAt(index: Int, value: Char) ``` Sets [Char](../kotlin/-char/index#kotlin.Char) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-char-at#kotlin.native%24setCharAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Char)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-char-at#kotlin.native%24setCharAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Char)/index) is outside of array boundaries. kotlin getShortAt getShortAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [getShortAt](get-short-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.getShortAt(index: Int): Short ``` Gets [Short](../kotlin/-short/index#kotlin.Short) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](get-short-at#kotlin.native%24getShortAt(kotlin.ByteArray,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](get-short-at#kotlin.native%24getShortAt(kotlin.ByteArray,%20kotlin.Int)/index) is outside of array boundaries. kotlin setUnhandledExceptionHook setUnhandledExceptionHook ========================= [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setUnhandledExceptionHook](set-unhandled-exception-hook) **Platform and version requirements:** Native (1.3) ``` fun setUnhandledExceptionHook(     hook: ReportUnhandledExceptionHook? ): ReportUnhandledExceptionHook? ``` Installs an unhandled exception hook and returns an old hook, or `null` if no user-defined hooks were previously set. The hook is invoked whenever there is an uncaught exception reaching the boundaries of the Kotlin world, i.e. top-level `main()`, worker boundary, or when Objective-C to Kotlin call not marked with `@Throws` throws an exception. The hook is in full control of how to process an unhandled exception and proceed further. For hooks that terminate an application, it is recommended to use [terminateWithUnhandledException](terminate-with-unhandled-exception) to be consistent with a default behaviour when no hooks are set. Set or default hook is also invoked by [processUnhandledException](process-unhandled-exception). With the legacy MM the hook must be a frozen lambda so that it could be called from any thread/worker. **Platform and version requirements:** Native (1.3) ``` fun setUnhandledExceptionHook(     hook: ReportUnhandledExceptionHook ): ReportUnhandledExceptionHook? ``` **Deprecated:** Provided for binary compatibility kotlin ReportUnhandledExceptionHook ReportUnhandledExceptionHook ============================ [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [ReportUnhandledExceptionHook](-report-unhandled-exception-hook) **Platform and version requirements:** Native (1.3) ``` typealias ReportUnhandledExceptionHook = (Throwable) -> Unit ``` Typealias describing custom exception reporting hook. kotlin setShortAt setShortAt ========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setShortAt](set-short-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setShortAt(index: Int, value: Short) ``` Sets [Short](../kotlin/-short/index#kotlin.Short) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-short-at#kotlin.native%24setShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Short)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-short-at#kotlin.native%24setShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Short)/index) is outside of array boundaries. kotlin isExperimentalMM isExperimentalMM ================ [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [isExperimentalMM](is-experimental-m-m) **Platform and version requirements:** Native (1.3) ``` @ExperimentalStdlibApi fun isExperimentalMM(): Boolean ``` kotlin setIntAt setIntAt ======== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [setIntAt](set-int-at) **Platform and version requirements:** Native (1.3) ``` fun ByteArray.setIntAt(index: Int, value: Int) ``` Sets [Int](../kotlin/-int/index#kotlin.Int) out of the [ByteArray](../kotlin/-byte-array/index#kotlin.ByteArray) byte buffer at specified index [index](set-int-at#kotlin.native%24setIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/index) Exceptions ---------- `ArrayIndexOutOfBoundsException` - if [index](set-int-at#kotlin.native%24setIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/index) is outside of array boundaries. kotlin asUCPointer asUCPointer =========== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [asUCPointer](as-u-c-pointer) **Platform and version requirements:** Native (1.3) ``` fun ImmutableBlob.asUCPointer(     offset: Int = 0 ): CPointer<UByteVar> ``` kotlin initRuntimeIfNeeded initRuntimeIfNeeded =================== [kotlin-stdlib](../../../../../index) / [kotlin.native](index) / [initRuntimeIfNeeded](init-runtime-if-needed) **Platform and version requirements:** Native (1.3) ``` fun initRuntimeIfNeeded() ``` Initializes Kotlin runtime for the current thread, if not inited already. kotlin ObjCName ObjCName ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ObjCName](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION]) @ExperimentalObjCName annotation class ObjCName ``` Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. Parameters ---------- `exact` - specifies if the name of a class should be interpreted as the exact name. E.g. the compiler won't add a top level prefix or the outer class names to exact names. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. ``` <init>(     name: String = "",     swiftName: String = "",     exact: Boolean = false) ``` Properties ---------- **Platform and version requirements:** Native (1.0) #### <exact> specifies if the name of a class should be interpreted as the exact name. E.g. the compiler won't add a top level prefix or the outer class names to exact names. ``` val exact: Boolean ``` **Platform and version requirements:** Native (1.0) #### <name> ``` val name: String ``` **Platform and version requirements:** Native (1.0) #### [swiftName](swift-name) ``` val swiftName: String ``` kotlin swiftName swiftName ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ObjCName](index) / [swiftName](swift-name) **Platform and version requirements:** Native (1.3) ``` val swiftName: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ObjCName](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>(     name: String = "",     swiftName: String = "",     exact: Boolean = false) ``` Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. Parameters ---------- `exact` - specifies if the name of a class should be interpreted as the exact name. E.g. the compiler won't add a top level prefix or the outer class names to exact names.
programming_docs
kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ObjCName](index) / <name> **Platform and version requirements:** Native (1.3) ``` val name: String ``` kotlin exact exact ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ObjCName](index) / <exact> **Platform and version requirements:** Native (1.3) ``` val exact: Boolean ``` specifies if the name of a class should be interpreted as the exact name. E.g. the compiler won't add a top level prefix or the outer class names to exact names. kotlin OsFamily OsFamily ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) **Platform and version requirements:** Native (1.3) ``` enum class OsFamily ``` Operating system family. Enum Values ----------- **Platform and version requirements:** Native (1.3) #### [UNKNOWN](-u-n-k-n-o-w-n) **Platform and version requirements:** Native (1.3) #### [MACOSX](-m-a-c-o-s-x) **Platform and version requirements:** Native (1.3) #### [IOS](-i-o-s) **Platform and version requirements:** Native (1.3) #### [LINUX](-l-i-n-u-x) **Platform and version requirements:** Native (1.3) #### [WINDOWS](-w-i-n-d-o-w-s) **Platform and version requirements:** Native (1.3) #### [ANDROID](-a-n-d-r-o-i-d) **Platform and version requirements:** Native (1.3) #### [WASM](-w-a-s-m) **Platform and version requirements:** Native (1.3) #### [TVOS](-t-v-o-s) **Platform and version requirements:** Native (1.3) #### [WATCHOS](-w-a-t-c-h-o-s) kotlin LINUX LINUX ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [LINUX](-l-i-n-u-x) **Platform and version requirements:** Native (1.3) ``` LINUX ``` kotlin WINDOWS WINDOWS ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [WINDOWS](-w-i-n-d-o-w-s) **Platform and version requirements:** Native (1.3) ``` WINDOWS ``` kotlin ANDROID ANDROID ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [ANDROID](-a-n-d-r-o-i-d) **Platform and version requirements:** Native (1.3) ``` ANDROID ``` kotlin UNKNOWN UNKNOWN ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [UNKNOWN](-u-n-k-n-o-w-n) **Platform and version requirements:** Native (1.3) ``` UNKNOWN ``` kotlin WASM WASM ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [WASM](-w-a-s-m) **Platform and version requirements:** Native (1.3) ``` WASM ``` kotlin MACOSX MACOSX ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [MACOSX](-m-a-c-o-s-x) **Platform and version requirements:** Native (1.3) ``` MACOSX ``` kotlin IOS IOS === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [IOS](-i-o-s) **Platform and version requirements:** Native (1.3) ``` IOS ``` kotlin TVOS TVOS ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [TVOS](-t-v-o-s) **Platform and version requirements:** Native (1.3) ``` TVOS ``` kotlin WATCHOS WATCHOS ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [OsFamily](index) / [WATCHOS](-w-a-t-c-h-o-s) **Platform and version requirements:** Native (1.3) ``` WATCHOS ``` kotlin RefinesInSwift RefinesInSwift ============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [RefinesInSwift](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) @ExperimentalObjCRefinement annotation class RefinesInSwift ``` Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. Annotation processors that refine the public API in Swift can annotate their annotations with this meta-annotation to automatically hide the annotated declarations from Swift. See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift) macro for more information on refining Objective-C declarations in Swift. Note: only annotations with [AnnotationTarget.FUNCTION](../../kotlin.annotation/-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION) and/or [AnnotationTarget.PROPERTY](../../kotlin.annotation/-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY) are supported. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [RefinesInSwift](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>() ``` Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. Annotation processors that refine the public API in Swift can annotate their annotations with this meta-annotation to automatically hide the annotated declarations from Swift. See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift) macro for more information on refining Objective-C declarations in Swift. Note: only annotations with [AnnotationTarget.FUNCTION](../../kotlin.annotation/-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION) and/or [AnnotationTarget.PROPERTY](../../kotlin.annotation/-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY) are supported. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ImmutableBlob](index) / <size> **Platform and version requirements:** Native (1.3) ``` val size: Int ``` kotlin ImmutableBlob ImmutableBlob ============= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ImmutableBlob](index) **Platform and version requirements:** Native (1.3) ``` class ImmutableBlob ``` An immutable compile-time array of bytes. Properties ---------- **Platform and version requirements:** Native (1.3) #### <size> ``` val size: Int ``` Functions --------- **Platform and version requirements:** Native (1.3) #### <get> ``` operator fun get(index: Int): Byte ``` **Platform and version requirements:** Native (1.3) #### <iterator> Creates an iterator over the elements of the array. ``` operator fun iterator(): ByteIterator ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [asCPointer](../as-c-pointer) Returns stable C pointer to data at certain [offset](../as-c-pointer#kotlin.native%24asCPointer(kotlin.native.ImmutableBlob,%20kotlin.Int)/offset), useful as a way to pass resource to C APIs. ``` fun ImmutableBlob.asCPointer(     offset: Int = 0 ): CPointer<ByteVar> ``` **Platform and version requirements:** Native (1.3) #### [asUCPointer](../as-u-c-pointer) ``` fun ImmutableBlob.asUCPointer(     offset: Int = 0 ): CPointer<UByteVar> ``` **Platform and version requirements:** Native (1.3) #### [toByteArray](../to-byte-array) Copies the data from this blob into a new [ByteArray](../../kotlin/-byte-array/index#kotlin.ByteArray). ``` fun ImmutableBlob.toByteArray(     startIndex: Int = 0,     endIndex: Int = size ): ByteArray ``` **Platform and version requirements:** Native (1.3) #### [toUByteArray](../to-u-byte-array) Copies the data from this blob into a new UByteArray. ``` fun ImmutableBlob.toUByteArray(     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ImmutableBlob](index) / <iterator> **Platform and version requirements:** Native (1.3) ``` operator fun iterator(): ByteIterator ``` Creates an iterator over the elements of the array. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ImmutableBlob](index) / <get> **Platform and version requirements:** Native (1.3) ``` operator fun get(index: Int): Byte ``` kotlin HiddenFromObjC HiddenFromObjC ============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [HiddenFromObjC](index) **Platform and version requirements:** Native (1.3) ``` @HidesFromObjC @Target([AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION]) @ExperimentalObjCRefinement annotation class HiddenFromObjC ``` Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [HiddenFromObjC](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>() ``` Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. kotlin CpuArchitecture CpuArchitecture =============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) **Platform and version requirements:** Native (1.3) ``` enum class CpuArchitecture ``` Central Processor Unit architecture. Enum Values ----------- **Platform and version requirements:** Native (1.3) #### [UNKNOWN](-u-n-k-n-o-w-n) **Platform and version requirements:** Native (1.3) #### [ARM32](-a-r-m32) **Platform and version requirements:** Native (1.3) #### [ARM64](-a-r-m64) **Platform and version requirements:** Native (1.3) #### [X86](-x86) **Platform and version requirements:** Native (1.3) #### [X64](-x64) **Platform and version requirements:** Native (1.3) #### [MIPS32](-m-i-p-s32) **Platform and version requirements:** Native (1.3) #### [MIPSEL32](-m-i-p-s-e-l32) **Platform and version requirements:** Native (1.3) #### [WASM32](-w-a-s-m32) Properties ---------- **Platform and version requirements:** Native (1.3) #### <bitness> ``` val bitness: Int ``` kotlin ARM64 ARM64 ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [ARM64](-a-r-m64) **Platform and version requirements:** Native (1.3) ``` ARM64 ``` kotlin bitness bitness ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / <bitness> **Platform and version requirements:** Native (1.3) ``` val bitness: Int ``` kotlin ARM32 ARM32 ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [ARM32](-a-r-m32) **Platform and version requirements:** Native (1.3) ``` ARM32 ``` kotlin MIPS32 MIPS32 ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [MIPS32](-m-i-p-s32) **Platform and version requirements:** Native (1.3) ``` MIPS32 ``` kotlin WASM32 WASM32 ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [WASM32](-w-a-s-m32) **Platform and version requirements:** Native (1.3) ``` WASM32 ``` kotlin UNKNOWN UNKNOWN ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [UNKNOWN](-u-n-k-n-o-w-n) **Platform and version requirements:** Native (1.3) ``` UNKNOWN ``` kotlin MIPSEL32 MIPSEL32 ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [MIPSEL32](-m-i-p-s-e-l32) **Platform and version requirements:** Native (1.3) ``` MIPSEL32 ``` kotlin X86 X86 === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [X86](-x86) **Platform and version requirements:** Native (1.3) ``` X86 ``` kotlin X64 X64 === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CpuArchitecture](index) / [X64](-x64) **Platform and version requirements:** Native (1.3) ``` X64 ``` kotlin IncorrectDereferenceException IncorrectDereferenceException ============================= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [IncorrectDereferenceException](index) **Platform and version requirements:** Native (1.3) ``` class IncorrectDereferenceException : RuntimeException ``` Exception thrown when top level variable is accessed from incorrect execution context. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` IncorrectDereferenceException() ``` ``` IncorrectDereferenceException(message: String) ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../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.native](../index) / [IncorrectDereferenceException](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` IncorrectDereferenceException() ``` ``` IncorrectDereferenceException(message: String) ``` kotlin RetainForTarget RetainForTarget =============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [RetainForTarget](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.CLASS]) annotation class RetainForTarget ``` Preserve the function entry point during global optimizations, only for the given target. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Preserve the function entry point during global optimizations, only for the given target. ``` RetainForTarget(target: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <target> ``` val target: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [RetainForTarget](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` RetainForTarget(target: String) ``` Preserve the function entry point during global optimizations, only for the given target. kotlin target target ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [RetainForTarget](index) / <target> **Platform and version requirements:** Native (1.3) ``` val target: String ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <size> **Platform and version requirements:** Native (1.3) ``` var size: Int ``` Actual number of bits available in the set. All bits with indices >= size assumed to be 0 kotlin previousBit previousBit =========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [previousBit](previous-bit) **Platform and version requirements:** Native (1.3) ``` fun previousBit(startIndex: Int, lookFor: Boolean): Int ``` Returns the biggest index of a bit which value is [lookFor](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/lookFor) before [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex). If [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex) >= <size> returns -1 kotlin BitSet BitSet ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) **Platform and version requirements:** Native (1.3) ``` class BitSet ``` A vector of bits growing if necessary and allowing one to set/clear/read bits from it by a bit index. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Creates a bit set of given length filling elements using initializer ``` BitSet(length: Int, initializer: (Int) -> Boolean) ``` creates an empty bit set with the specified <size> ``` BitSet(size: Int = ELEMENT_SIZE) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### [isEmpty](is-empty) True if this BitSet contains no bits set to true. ``` val isEmpty: Boolean ``` **Platform and version requirements:** Native (1.3) #### [lastTrueIndex](last-true-index) Returns an index of the last bit that has `true` value. Returns -1 if the set is empty. ``` val lastTrueIndex: Int ``` **Platform and version requirements:** Native (1.3) #### <size> Actual number of bits available in the set. All bits with indices >= size assumed to be 0 ``` var size: Int ``` Functions --------- **Platform and version requirements:** Native (1.3) #### <and> Performs a logical and operation over corresponding bits of this and [another](and#kotlin.native.BitSet%24and(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. ``` fun and(another: BitSet) ``` **Platform and version requirements:** Native (1.3) #### [andNot](and-not) Performs a logical and + not operations over corresponding bits of this and [another](and-not#kotlin.native.BitSet%24andNot(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. ``` fun andNot(another: BitSet) ``` **Platform and version requirements:** Native (1.3) #### <clear> Clears the bit specified ``` fun clear(index: Int) ``` ``` fun clear(range: IntRange) ``` Clears the bits with indices between [from](clear#kotlin.native.BitSet%24clear(kotlin.Int,%20kotlin.Int)/from) (inclusive) and [to](clear#kotlin.native.BitSet%24clear(kotlin.Int,%20kotlin.Int)/to) (exclusive) to the specified value. ``` fun clear(from: Int, to: Int) ``` Sets all bits in the BitSet to `false`. ``` fun clear() ``` **Platform and version requirements:** Native (1.3) #### <equals> 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) #### <flip> Reverses the bit specified. ``` fun flip(index: Int) ``` Reverses the bits with indices between [from](flip#kotlin.native.BitSet%24flip(kotlin.Int,%20kotlin.Int)/from) (inclusive) and [to](flip#kotlin.native.BitSet%24flip(kotlin.Int,%20kotlin.Int)/to) (exclusive). ``` fun flip(from: Int, to: Int) ``` Reverses the bits from the range specified. ``` fun flip(range: IntRange) ``` **Platform and version requirements:** Native (1.3) #### <get> Returns a value of a bit with the [index](get#kotlin.native.BitSet%24get(kotlin.Int)/index) specified. ``` operator fun get(index: Int): 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:** Native (1.3) #### <intersects> Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet. ``` fun intersects(another: BitSet): Boolean ``` **Platform and version requirements:** Native (1.3) #### [nextClearBit](next-clear-bit) Returns an index of a next bit which value is `false` after [startIndex](next-clear-bit#kotlin.native.BitSet%24nextClearBit(kotlin.Int)/startIndex) (inclusive). Returns <size> if there is no such bits between [startIndex](next-clear-bit#kotlin.native.BitSet%24nextClearBit(kotlin.Int)/startIndex) and <size> - 1 assuming that the set has an infinite sequence of `false` bits after (size - 1)-th. ``` fun nextClearBit(startIndex: Int = 0): Int ``` **Platform and version requirements:** Native (1.3) #### [nextSetBit](next-set-bit) Returns an index of a next bit which value is `true` after [startIndex](next-set-bit#kotlin.native.BitSet%24nextSetBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits after [startIndex](next-set-bit#kotlin.native.BitSet%24nextSetBit(kotlin.Int)/startIndex). ``` fun nextSetBit(startIndex: Int = 0): Int ``` **Platform and version requirements:** Native (1.3) #### <or> Performs a logical or operation over corresponding bits of this and [another](or#kotlin.native.BitSet%24or(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. ``` fun or(another: BitSet) ``` **Platform and version requirements:** Native (1.3) #### [previousBit](previous-bit) Returns the biggest index of a bit which value is [lookFor](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/lookFor) before [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex). If [startIndex](previous-bit#kotlin.native.BitSet%24previousBit(kotlin.Int,%20kotlin.Boolean)/startIndex) >= <size> returns -1 ``` fun previousBit(startIndex: Int, lookFor: Boolean): Int ``` **Platform and version requirements:** Native (1.3) #### [previousClearBit](previous-clear-bit) Returns the biggest index of a bit which value is `false` before [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) or if [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) == -1. If [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) >= size will return [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) assuming that the set has an infinite sequence of `false` bits after (size - 1)-th. ``` fun previousClearBit(startIndex: Int): Int ``` **Platform and version requirements:** Native (1.3) #### [previousSetBit](previous-set-bit) Returns the biggest index of a bit which value is `true` before [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) or if [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) == -1. If [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) >= size will search from (size - 1)-th bit. ``` fun previousSetBit(startIndex: Int): Int ``` **Platform and version requirements:** Native (1.3) #### <set> Set the bit specified to the specified value. ``` fun set(index: Int, value: Boolean = true) ``` Sets the bits with indices between [from](set#kotlin.native.BitSet%24set(kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/from) (inclusive) and [to](set#kotlin.native.BitSet%24set(kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/to) (exclusive) to the specified value. ``` fun set(from: Int, to: Int, value: Boolean = true) ``` Sets the bits from the range specified to the specified value. ``` fun set(range: IntRange, value: Boolean = true) ``` **Platform and version requirements:** Native (1.3) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` **Platform and version requirements:** Native (1.3) #### <xor> Performs a logical xor operation over corresponding bits of this and [another](xor#kotlin.native.BitSet%24xor(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. ``` fun xor(another: BitSet) ```
programming_docs
kotlin lastTrueIndex lastTrueIndex ============= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [lastTrueIndex](last-true-index) **Platform and version requirements:** Native (1.3) ``` val lastTrueIndex: Int ``` Returns an index of the last bit that has `true` value. Returns -1 if the set is empty. kotlin flip flip ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <flip> **Platform and version requirements:** Native (1.3) ``` fun flip(index: Int) ``` Reverses the bit specified. **Platform and version requirements:** Native (1.3) ``` fun flip(from: Int, to: Int) ``` Reverses the bits with indices between [from](flip#kotlin.native.BitSet%24flip(kotlin.Int,%20kotlin.Int)/from) (inclusive) and [to](flip#kotlin.native.BitSet%24flip(kotlin.Int,%20kotlin.Int)/to) (exclusive). **Platform and version requirements:** Native (1.3) ``` fun flip(range: IntRange) ``` Reverses the bits from the range specified. kotlin previousSetBit previousSetBit ============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [previousSetBit](previous-set-bit) **Platform and version requirements:** Native (1.3) ``` fun previousSetBit(startIndex: Int): Int ``` Returns the biggest index of a bit which value is `true` before [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) or if [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) == -1. If [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) >= size will search from (size - 1)-th bit. Exceptions ---------- `IndexOutOfBoundException` - if [startIndex](previous-set-bit#kotlin.native.BitSet%24previousSetBit(kotlin.Int)/startIndex) < -1. kotlin andNot andNot ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [andNot](and-not) **Platform and version requirements:** Native (1.3) ``` fun andNot(another: BitSet) ``` Performs a logical and + not operations over corresponding bits of this and [another](and-not#kotlin.native.BitSet%24andNot(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. kotlin previousClearBit previousClearBit ================ [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [previousClearBit](previous-clear-bit) **Platform and version requirements:** Native (1.3) ``` fun previousClearBit(startIndex: Int): Int ``` Returns the biggest index of a bit which value is `false` before [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits before [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) or if [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) == -1. If [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) >= size will return [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) assuming that the set has an infinite sequence of `false` bits after (size - 1)-th. Exceptions ---------- `IndexOutOfBoundException` - if [startIndex](previous-clear-bit#kotlin.native.BitSet%24previousClearBit(kotlin.Int)/startIndex) < -1. kotlin nextClearBit nextClearBit ============ [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [nextClearBit](next-clear-bit) **Platform and version requirements:** Native (1.3) ``` fun nextClearBit(startIndex: Int = 0): Int ``` Returns an index of a next bit which value is `false` after [startIndex](next-clear-bit#kotlin.native.BitSet%24nextClearBit(kotlin.Int)/startIndex) (inclusive). Returns <size> if there is no such bits between [startIndex](next-clear-bit#kotlin.native.BitSet%24nextClearBit(kotlin.Int)/startIndex) and <size> - 1 assuming that the set has an infinite sequence of `false` bits after (size - 1)-th. Exceptions ---------- `IndexOutOfBoundException` - if [startIndex](next-clear-bit#kotlin.native.BitSet%24nextClearBit(kotlin.Int)/startIndex) < 0. kotlin intersects intersects ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <intersects> **Platform and version requirements:** Native (1.3) ``` fun intersects(another: BitSet): Boolean ``` Returns true if the specified BitSet has any bits set to true that are also set to true in this BitSet. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](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.native](../index) / [BitSet](index) / <and> **Platform and version requirements:** Native (1.3) ``` fun and(another: BitSet) ``` Performs a logical and operation over corresponding bits of this and [another](and#kotlin.native.BitSet%24and(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [toString](to-string) **Platform and version requirements:** Native (1.3) ``` fun toString(): String ``` Returns a string representation of the object. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` BitSet(length: Int, initializer: (Int) -> Boolean) ``` Creates a bit set of given length filling elements using initializer **Platform and version requirements:** Native (1.3) ``` BitSet(size: Int = ELEMENT_SIZE) ``` creates an empty bit set with the specified <size> Parameters ---------- `size` - the size of one element in the array used to store bits. **Constructor** creates an empty bit set with the specified <size> kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <xor> **Platform and version requirements:** Native (1.3) ``` fun xor(another: BitSet) ``` Performs a logical xor operation over corresponding bits of this and [another](xor#kotlin.native.BitSet%24xor(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <equals> **Platform and version requirements:** Native (1.3) ``` 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. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <clear> **Platform and version requirements:** Native (1.3) ``` fun clear(index: Int) ``` ``` fun clear(range: IntRange) ``` Clears the bit specified **Platform and version requirements:** Native (1.3) ``` fun clear(from: Int, to: Int) ``` Clears the bits with indices between [from](clear#kotlin.native.BitSet%24clear(kotlin.Int,%20kotlin.Int)/from) (inclusive) and [to](clear#kotlin.native.BitSet%24clear(kotlin.Int,%20kotlin.Int)/to) (exclusive) to the specified value. **Platform and version requirements:** Native (1.3) ``` fun clear() ``` Sets all bits in the BitSet to `false`. kotlin nextSetBit nextSetBit ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [nextSetBit](next-set-bit) **Platform and version requirements:** Native (1.3) ``` fun nextSetBit(startIndex: Int = 0): Int ``` Returns an index of a next bit which value is `true` after [startIndex](next-set-bit#kotlin.native.BitSet%24nextSetBit(kotlin.Int)/startIndex) (inclusive). Returns -1 if there is no such bits after [startIndex](next-set-bit#kotlin.native.BitSet%24nextSetBit(kotlin.Int)/startIndex). Exceptions ---------- `IndexOutOfBoundException` - if [startIndex](next-set-bit#kotlin.native.BitSet%24nextSetBit(kotlin.Int)/startIndex) < 0. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / [isEmpty](is-empty) **Platform and version requirements:** Native (1.3) ``` val isEmpty: Boolean ``` True if this BitSet contains no bits set to true. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <set> **Platform and version requirements:** Native (1.3) ``` fun set(index: Int, value: Boolean = true) ``` Set the bit specified to the specified value. **Platform and version requirements:** Native (1.3) ``` fun set(from: Int, to: Int, value: Boolean = true) ``` Sets the bits with indices between [from](set#kotlin.native.BitSet%24set(kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/from) (inclusive) and [to](set#kotlin.native.BitSet%24set(kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/to) (exclusive) to the specified value. **Platform and version requirements:** Native (1.3) ``` fun set(range: IntRange, value: Boolean = true) ``` Sets the bits from the range specified to the specified value. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <get> **Platform and version requirements:** Native (1.3) ``` operator fun get(index: Int): Boolean ``` Returns a value of a bit with the [index](get#kotlin.native.BitSet%24get(kotlin.Int)/index) specified. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [BitSet](index) / <or> **Platform and version requirements:** Native (1.3) ``` fun or(another: BitSet) ``` Performs a logical or operation over corresponding bits of this and [another](or#kotlin.native.BitSet%24or(kotlin.native.BitSet)/another) BitSets. The result is saved in this BitSet. kotlin EagerInitialization EagerInitialization =================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [EagerInitialization](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.PROPERTY]) @ExperimentalStdlibApi annotation class EagerInitialization ``` **Deprecated:** This annotation is a temporal migration assistance and may be removed in the future releases, please consider filing an issue about the case where it is needed Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". This annotation is intended to be used only as a temporal workaround and will be removed through the regular deprecation cycle as soon as the new initialization scheme will become the default one. For the usages that cannot be emulated on the new initialization scheme without this annotation, it is strongly recommended to report them during the transition period, so the proper replacement can be introduced. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". ``` EagerInitialization() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [EagerInitialization](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` EagerInitialization() ``` Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". This annotation is intended to be used only as a temporal workaround and will be removed through the regular deprecation cycle as soon as the new initialization scheme will become the default one. For the usages that cannot be emulated on the new initialization scheme without this annotation, it is strongly recommended to report them during the transition period, so the proper replacement can be introduced. kotlin Retain Retain ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Retain](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.CLASS]) annotation class Retain ``` Preserve the function entry point during global optimizations. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Preserve the function entry point during global optimizations. ``` Retain() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Retain](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` Retain() ``` Preserve the function entry point during global optimizations. kotlin FileFailedToInitializeException FileFailedToInitializeException =============================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [FileFailedToInitializeException](index) **Platform and version requirements:** Native (1.3) ``` @ExperimentalStdlibApi class FileFailedToInitializeException :      RuntimeException ``` Exception thrown when there was an error during file initalization. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` FileFailedToInitializeException() ``` ``` FileFailedToInitializeException(message: String) ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [getStackTraceAddresses](../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.native](../index) / [FileFailedToInitializeException](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` FileFailedToInitializeException() ``` ``` FileFailedToInitializeException(message: String) ``` kotlin isMemoryLeakCheckerActive isMemoryLeakCheckerActive ========================= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [isMemoryLeakCheckerActive](is-memory-leak-checker-active) **Platform and version requirements:** Native (1.3) ``` var isMemoryLeakCheckerActive: Boolean ``` If the memory leak checker is activated, by default `true` in debug mode, `false` in release. When memory leak checker is activated, and leak is detected during last Kotlin context deinitialization process - error message with leak information is printed and application execution is aborted. **See Also** [isDebugBinary](is-debug-binary) kotlin Platform Platform ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) **Platform and version requirements:** Native (1.3) ``` object Platform ``` Object describing the current platform program executes upon. Properties ---------- **Platform and version requirements:** Native (1.3) #### [canAccessUnaligned](can-access-unaligned) Check if current architecture allows unaligned access to wider than byte locations. ``` val canAccessUnaligned: Boolean ``` **Platform and version requirements:** Native (1.3) #### [cpuArchitecture](cpu-architecture) Architechture of the CPU program executes upon. ``` val cpuArchitecture: CpuArchitecture ``` **Platform and version requirements:** Native (1.3) #### [isCleanersLeakCheckerActive](is-cleaners-leak-checker-active) ``` var isCleanersLeakCheckerActive: Boolean ``` **Platform and version requirements:** Native (1.3) #### [isDebugBinary](is-debug-binary) If binary was compiled in debug mode. ``` val isDebugBinary: Boolean ``` **Platform and version requirements:** Native (1.3) #### [isFreezingEnabled](is-freezing-enabled) If freezing is enabled. ``` val isFreezingEnabled: Boolean ``` **Platform and version requirements:** Native (1.3) #### [isLittleEndian](is-little-endian) Check if byte order of the current platform is least significant byte (LSB) first, aka little endian. ``` val isLittleEndian: Boolean ``` **Platform and version requirements:** Native (1.3) #### [isMemoryLeakCheckerActive](is-memory-leak-checker-active) If the memory leak checker is activated, by default `true` in debug mode, `false` in release. When memory leak checker is activated, and leak is detected during last Kotlin context deinitialization process - error message with leak information is printed and application execution is aborted. ``` var isMemoryLeakCheckerActive: Boolean ``` **Platform and version requirements:** Native (1.3) #### [memoryModel](memory-model) Memory model binary was compiled with. ``` val memoryModel: MemoryModel ``` **Platform and version requirements:** Native (1.3) #### [osFamily](os-family) Operating system family program executes upon. ``` val osFamily: OsFamily ``` Functions --------- **Platform and version requirements:** Native (1.3) #### [getAvailableProcessors](get-available-processors) The number of logical processors available. ``` fun getAvailableProcessors(): Int ``` kotlin cpuArchitecture cpuArchitecture =============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [cpuArchitecture](cpu-architecture) **Platform and version requirements:** Native (1.3) ``` val cpuArchitecture: CpuArchitecture ``` Architechture of the CPU program executes upon.
programming_docs
kotlin memoryModel memoryModel =========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [memoryModel](memory-model) **Platform and version requirements:** Native (1.3) ``` val memoryModel: MemoryModel ``` Memory model binary was compiled with. kotlin osFamily osFamily ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [osFamily](os-family) **Platform and version requirements:** Native (1.3) ``` val osFamily: OsFamily ``` Operating system family program executes upon. kotlin isDebugBinary isDebugBinary ============= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [isDebugBinary](is-debug-binary) **Platform and version requirements:** Native (1.3) ``` val isDebugBinary: Boolean ``` If binary was compiled in debug mode. kotlin canAccessUnaligned canAccessUnaligned ================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [canAccessUnaligned](can-access-unaligned) **Platform and version requirements:** Native (1.3) ``` val canAccessUnaligned: Boolean ``` Check if current architecture allows unaligned access to wider than byte locations. kotlin isCleanersLeakCheckerActive isCleanersLeakCheckerActive =========================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [isCleanersLeakCheckerActive](is-cleaners-leak-checker-active) **Platform and version requirements:** Native (1.3) ``` var isCleanersLeakCheckerActive: Boolean ``` kotlin getAvailableProcessors getAvailableProcessors ====================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [getAvailableProcessors](get-available-processors) **Platform and version requirements:** Native (1.3) ``` @ExperimentalStdlibApi fun getAvailableProcessors(): Int ``` The number of logical processors available. Can be not equal to the number of processors in the system if some restrictions on processor usage were successfully detected. Some kinds of processor usage restrictions are not detected, for now, e.g., CPU quotas in containers. The value is computed on each usage. It can change if some OS scheduler API restricts the process during runtime. Also, value can differ on different threads if some thread-specific scheduler API was used. If one considers the value to be inaccurate and wants another one to be used, it can be overridden by `KOTLIN_NATIVE_AVAILABLE_PROCESSORS` environment variable. When the variable is set and contains a value that is not positive [Int](../../kotlin/-int/index#kotlin.Int), [IllegalStateException](../../kotlin/-illegal-state-exception/index#kotlin.IllegalStateException) will be thrown. kotlin isLittleEndian isLittleEndian ============== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [isLittleEndian](is-little-endian) **Platform and version requirements:** Native (1.3) ``` val isLittleEndian: Boolean ``` Check if byte order of the current platform is least significant byte (LSB) first, aka little endian. kotlin isFreezingEnabled isFreezingEnabled ================= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Platform](index) / [isFreezingEnabled](is-freezing-enabled) **Platform and version requirements:** Native (1.3) ``` val isFreezingEnabled: Boolean ``` If freezing is enabled. This value would be false, only if binary option `freezing` is equal to `disabled`. This is default when [memoryModel](memory-model) is equal to [MemoryModel.EXPERIMENTAL](../-memory-model/-e-x-p-e-r-i-m-e-n-t-a-l). kotlin HidesFromObjC HidesFromObjC ============= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [HidesFromObjC](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) @ExperimentalObjCRefinement annotation class HidesFromObjC ``` Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. Annotation processors that refine the public Objective-C API can annotate their annotations with this meta-annotation to have the original declarations automatically removed from the public API. Note: only annotations with [AnnotationTarget.FUNCTION](../../kotlin.annotation/-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION) and/or [AnnotationTarget.PROPERTY](../../kotlin.annotation/-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY) are supported. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [HidesFromObjC](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>() ``` Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. Annotation processors that refine the public Objective-C API can annotate their annotations with this meta-annotation to have the original declarations automatically removed from the public API. Note: only annotations with [AnnotationTarget.FUNCTION](../../kotlin.annotation/-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION) and/or [AnnotationTarget.PROPERTY](../../kotlin.annotation/-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY) are supported. kotlin ShouldRefineInSwift ShouldRefineInSwift =================== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ShouldRefineInSwift](index) **Platform and version requirements:** Native (1.3) ``` @RefinesInSwift @Target([AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION]) @ExperimentalObjCRefinement annotation class ShouldRefineInSwift ``` Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift) macro for more information on refining Objective-C declarations in Swift. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [ShouldRefineInSwift](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>() ``` Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift) macro for more information on refining Objective-C declarations in Swift. kotlin SymbolName SymbolName ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [SymbolName](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION]) annotation class SymbolName ``` This is a dangerous deprecated and internal annotation. Please avoid using it. If you absolutely need to use the annotation, please comment at [KT-46649](https://youtrack.jetbrains.com/issue/KT-46649). Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) This is a dangerous deprecated and internal annotation. Please avoid using it. ``` SymbolName(name: String) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <name> ``` val name: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [SymbolName](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` SymbolName(name: String) ``` This is a dangerous deprecated and internal annotation. Please avoid using it. If you absolutely need to use the annotation, please comment at [KT-46649](https://youtrack.jetbrains.com/issue/KT-46649). kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [SymbolName](index) / <name> **Platform and version requirements:** Native (1.3) ``` val name: String ``` kotlin MemoryModel MemoryModel =========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [MemoryModel](index) **Platform and version requirements:** Native (1.3) ``` enum class MemoryModel ``` Memory model. Enum Values ----------- **Platform and version requirements:** Native (1.3) #### [STRICT](-s-t-r-i-c-t) **Platform and version requirements:** Native (1.3) #### [RELAXED](-r-e-l-a-x-e-d) **Platform and version requirements:** Native (1.3) #### [EXPERIMENTAL](-e-x-p-e-r-i-m-e-n-t-a-l) kotlin EXPERIMENTAL EXPERIMENTAL ============ [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [MemoryModel](index) / [EXPERIMENTAL](-e-x-p-e-r-i-m-e-n-t-a-l) **Platform and version requirements:** Native (1.3) ``` EXPERIMENTAL ``` kotlin STRICT STRICT ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [MemoryModel](index) / [STRICT](-s-t-r-i-c-t) **Platform and version requirements:** Native (1.3) ``` STRICT ``` kotlin RELAXED RELAXED ======= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [MemoryModel](index) / [RELAXED](-r-e-l-a-x-e-d) **Platform and version requirements:** Native (1.3) ``` RELAXED ``` kotlin getULongAt getULongAt ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getULongAt](get-u-long-at) **Platform and version requirements:** Native (1.3) ``` fun getULongAt(index: Int): ULong ``` kotlin getFloatAt getFloatAt ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getFloatAt](get-float-at) **Platform and version requirements:** Native (1.3) ``` fun getFloatAt(index: Int): Float ``` kotlin getByteAt getByteAt ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getByteAt](get-byte-at) **Platform and version requirements:** Native (1.3) ``` fun getByteAt(index: Int): Byte ``` kotlin getIntAt getIntAt ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getIntAt](get-int-at) **Platform and version requirements:** Native (1.3) ``` fun getIntAt(index: Int): Int ``` kotlin getDoubleAt getDoubleAt =========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getDoubleAt](get-double-at) **Platform and version requirements:** Native (1.3) ``` fun getDoubleAt(index: Int): Double ``` kotlin Vector128 Vector128 ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) **Platform and version requirements:** Native (1.3) ``` class Vector128 ``` Functions --------- **Platform and version requirements:** Native (1.3) #### <equals> ``` fun equals(other: Vector128): Boolean ``` 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) #### [getByteAt](get-byte-at) ``` fun getByteAt(index: Int): Byte ``` **Platform and version requirements:** Native (1.3) #### [getDoubleAt](get-double-at) ``` fun getDoubleAt(index: Int): Double ``` **Platform and version requirements:** Native (1.3) #### [getFloatAt](get-float-at) ``` fun getFloatAt(index: Int): Float ``` **Platform and version requirements:** Native (1.3) #### [getIntAt](get-int-at) ``` fun getIntAt(index: Int): Int ``` **Platform and version requirements:** Native (1.3) #### [getLongAt](get-long-at) ``` fun getLongAt(index: Int): Long ``` **Platform and version requirements:** Native (1.3) #### [getUByteAt](get-u-byte-at) ``` fun getUByteAt(index: Int): UByte ``` **Platform and version requirements:** Native (1.3) #### [getUIntAt](get-u-int-at) ``` fun getUIntAt(index: Int): UInt ``` **Platform and version requirements:** Native (1.3) #### [getULongAt](get-u-long-at) ``` fun getULongAt(index: Int): ULong ``` **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:** Native (1.3) #### [toString](to-string) Returns a string representation of the object. ``` fun toString(): String ``` kotlin getUIntAt getUIntAt ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getUIntAt](get-u-int-at) **Platform and version requirements:** Native (1.3) ``` fun getUIntAt(index: Int): UInt ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](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 toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [toString](to-string) **Platform and version requirements:** Native (1.3) ``` fun toString(): String ``` Returns a string representation of the object. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Vector128): Boolean ``` **Platform and version requirements:** Native (1.3) ``` 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. kotlin getUByteAt getUByteAt ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getUByteAt](get-u-byte-at) **Platform and version requirements:** Native (1.3) ``` fun getUByteAt(index: Int): UByte ``` kotlin getLongAt getLongAt ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [Vector128](index) / [getLongAt](get-long-at) **Platform and version requirements:** Native (1.3) ``` fun getLongAt(index: Int): Long ``` kotlin CName CName ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CName](index) **Platform and version requirements:** Native (1.3) ``` @Target([AnnotationTarget.FUNCTION]) annotation class CName ``` Makes top level function available from C/C++ code with the given name. [externName](extern-name#kotlin.native.CName%24externName) controls the name of top level function, [shortName](short-name#kotlin.native.CName%24shortName) controls the short name. If [externName](extern-name#kotlin.native.CName%24externName) is empty, no top level declaration is being created. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) Makes top level function available from C/C++ code with the given name. ``` <init>(externName: String = "", shortName: String = "") ``` Properties ---------- **Platform and version requirements:** Native (1.0) #### [externName](extern-name) ``` val externName: String ``` **Platform and version requirements:** Native (1.0) #### [shortName](short-name) ``` val shortName: String ``` kotlin shortName shortName ========= [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CName](index) / [shortName](short-name) **Platform and version requirements:** Native (1.3) ``` val shortName: String ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CName](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>(externName: String = "", shortName: String = "") ``` Makes top level function available from C/C++ code with the given name. [externName](extern-name#kotlin.native.CName%24externName) controls the name of top level function, [shortName](short-name#kotlin.native.CName%24shortName) controls the short name. If [externName](extern-name#kotlin.native.CName%24externName) is empty, no top level declaration is being created. kotlin externName externName ========== [kotlin-stdlib](../../../../../../index) / [kotlin.native](../index) / [CName](index) / [externName](extern-name) **Platform and version requirements:** Native (1.3) ``` val externName: String ``` kotlin until until ===== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <until> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun Int.until(to: Byte): IntRange ``` ``` infix fun Long.until(to: Byte): LongRange ``` ``` infix fun Byte.until(to: Byte): IntRange ``` ``` infix fun Short.until(to: Byte): IntRange ``` ``` infix fun Char.until(to: Char): CharRange ``` ``` infix fun Int.until(to: Int): IntRange ``` ``` infix fun Long.until(to: Int): LongRange ``` ``` infix fun Byte.until(to: Int): IntRange ``` ``` infix fun Short.until(to: Int): IntRange ``` ``` infix fun Int.until(to: Long): LongRange ``` ``` infix fun Long.until(to: Long): LongRange ``` ``` infix fun Byte.until(to: Long): LongRange ``` ``` infix fun Short.until(to: Long): LongRange ``` ``` infix fun Int.until(to: Short): IntRange ``` ``` infix fun Long.until(to: Short): LongRange ``` ``` infix fun Byte.until(to: Short): IntRange ``` ``` infix fun Short.until(to: Short): IntRange ``` ``` infix fun UByte.until(to: UByte): UIntRange ``` ``` infix fun UInt.until(to: UInt): UIntRange ``` ``` infix fun ULong.until(to: ULong): ULongRange ``` ``` infix fun UShort.until(to: UShort): UIntRange ``` Returns a range from this value up to but excluding the specified [to](until#kotlin.ranges%24until(kotlin.Int,%20kotlin.Byte)/to) value. If the [to](until#kotlin.ranges%24until(kotlin.Int,%20kotlin.Byte)/to) value is less than or equal to `this` value, then the returned range is empty.
programming_docs
kotlin coerceAtMost coerceAtMost ============ [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [coerceAtMost](coerce-at-most) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T ``` Ensures that this value is not greater than the specified [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(DayOfWeek.FRIDAY.coerceAtMost(DayOfWeek.SATURDAY)) // FRIDAY println(DayOfWeek.FRIDAY.coerceAtMost(DayOfWeek.WEDNESDAY)) // WEDNESDAY //sampleEnd } ``` **Return** this value if it's less than or equal to the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue) or the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue) otherwise. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Byte.coerceAtMost(maximumValue: Byte): Byte ``` ``` fun Short.coerceAtMost(maximumValue: Short): Short ``` ``` fun Int.coerceAtMost(maximumValue: Int): Int ``` ``` fun Long.coerceAtMost(maximumValue: Long): Long ``` ``` fun Float.coerceAtMost(maximumValue: Float): Float ``` ``` fun Double.coerceAtMost(maximumValue: Double): Double ``` Ensures that this value is not greater than the specified [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.Byte,%20kotlin.Byte)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10.coerceAtMost(5)) // 5 println(10.coerceAtMost(20)) // 10 //sampleEnd } ``` **Return** this value if it's less than or equal to the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.Byte,%20kotlin.Byte)/maximumValue) or the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.Byte,%20kotlin.Byte)/maximumValue) otherwise. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.coerceAtMost(maximumValue: UInt): UInt ``` ``` fun ULong.coerceAtMost(maximumValue: ULong): ULong ``` ``` fun UByte.coerceAtMost(maximumValue: UByte): UByte ``` ``` fun UShort.coerceAtMost(maximumValue: UShort): UShort ``` Ensures that this value is not greater than the specified [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.UInt,%20kotlin.UInt)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10u.coerceAtMost(5u)) // 5 println(10u.coerceAtMost(20u)) // 10 //sampleEnd } ``` **Return** this value if it's less than or equal to the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.UInt,%20kotlin.UInt)/maximumValue) or the [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.UInt,%20kotlin.UInt)/maximumValue) otherwise. kotlin contains contains ======== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <contains> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun IntRange.contains(element: Int?): Boolean ``` ``` operator fun LongRange.contains(element: Long?): Boolean ``` ``` operator fun CharRange.contains(element: Char?): Boolean ``` ``` operator fun UIntRange.contains(element: UInt?): Boolean ``` ``` operator fun ULongRange.contains(element: ULong?): Boolean ``` Returns `true` if this range contains the specified [element](contains#kotlin.ranges%24contains(kotlin.ranges.IntRange,%20kotlin.Int?)/element). Always returns `false` if the [element](contains#kotlin.ranges%24contains(kotlin.ranges.IntRange,%20kotlin.Int?)/element) is `null`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("intRangeContains") operator fun ClosedRange<Int>.contains(     value: Byte ): Boolean ``` ``` @JvmName("longRangeContains") operator fun ClosedRange<Long>.contains(     value: Byte ): Boolean ``` ``` @JvmName("shortRangeContains") operator fun ClosedRange<Short>.contains(     value: Byte ): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("doubleRangeContains") operator fun ClosedRange<Double>.contains(     value: Byte ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("floatRangeContains") operator fun ClosedRange<Float>.contains(     value: Byte ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("intRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Int>.contains(     value: Byte ): Boolean ``` ``` @JvmName("longRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Long>.contains(     value: Byte ): Boolean ``` ``` @JvmName("shortRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Short>.contains(     value: Byte ): Boolean ``` ``` operator fun IntRange.contains(value: Byte): Boolean ``` ``` operator fun LongRange.contains(value: Byte): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("intRangeContains") operator fun ClosedRange<Int>.contains(     value: Double ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("longRangeContains") operator fun ClosedRange<Long>.contains(     value: Double ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("byteRangeContains") operator fun ClosedRange<Byte>.contains(     value: Double ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("shortRangeContains") operator fun ClosedRange<Short>.contains(     value: Double ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("floatRangeContains") operator fun ClosedRange<Float>.contains(     value: Double ): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("intRangeContains") operator fun ClosedRange<Int>.contains(     value: Float ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("longRangeContains") operator fun ClosedRange<Long>.contains(     value: Float ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("byteRangeContains") operator fun ClosedRange<Byte>.contains(     value: Float ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("shortRangeContains") operator fun ClosedRange<Short>.contains(     value: Float ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("doubleRangeContains") operator fun ClosedRange<Double>.contains(     value: Float ): Boolean ``` ``` @JvmName("doubleRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Double>.contains(     value: Float ): Boolean ``` ``` @JvmName("longRangeContains") operator fun ClosedRange<Long>.contains(     value: Int ): Boolean ``` ``` @JvmName("byteRangeContains") operator fun ClosedRange<Byte>.contains(     value: Int ): Boolean ``` ``` @JvmName("shortRangeContains") operator fun ClosedRange<Short>.contains(     value: Int ): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("doubleRangeContains") operator fun ClosedRange<Double>.contains(     value: Int ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("floatRangeContains") operator fun ClosedRange<Float>.contains(     value: Int ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("longRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Long>.contains(     value: Int ): Boolean ``` ``` @JvmName("byteRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Byte>.contains(     value: Int ): Boolean ``` ``` @JvmName("shortRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Short>.contains(     value: Int ): Boolean ``` ``` operator fun LongRange.contains(value: Int): Boolean ``` ``` @JvmName("intRangeContains") operator fun ClosedRange<Int>.contains(     value: Long ): Boolean ``` ``` @JvmName("byteRangeContains") operator fun ClosedRange<Byte>.contains(     value: Long ): Boolean ``` ``` @JvmName("shortRangeContains") operator fun ClosedRange<Short>.contains(     value: Long ): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("doubleRangeContains") operator fun ClosedRange<Double>.contains(     value: Long ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("floatRangeContains") operator fun ClosedRange<Float>.contains(     value: Long ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("intRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Int>.contains(     value: Long ): Boolean ``` ``` @JvmName("byteRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Byte>.contains(     value: Long ): Boolean ``` ``` @JvmName("shortRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Short>.contains(     value: Long ): Boolean ``` ``` operator fun IntRange.contains(value: Long): Boolean ``` ``` @JvmName("intRangeContains") operator fun ClosedRange<Int>.contains(     value: Short ): Boolean ``` ``` @JvmName("longRangeContains") operator fun ClosedRange<Long>.contains(     value: Short ): Boolean ``` ``` @JvmName("byteRangeContains") operator fun ClosedRange<Byte>.contains(     value: Short ): Boolean ``` ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("doubleRangeContains") operator fun ClosedRange<Double>.contains(     value: Short ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @DeprecatedSinceKotlin("1.3", "1.4", "1.5") @JvmName("floatRangeContains") operator fun ClosedRange<Float>.contains(     value: Short ): Boolean ``` **Deprecated:** This `contains` operation mixing integer and floating point arguments has ambiguous semantics and is going to be removed. ``` @JvmName("intRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Int>.contains(     value: Short ): Boolean ``` ``` @JvmName("longRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Long>.contains(     value: Short ): Boolean ``` ``` @JvmName("byteRangeContains") @ExperimentalStdlibApi operator fun OpenEndRange<Byte>.contains(     value: Short ): Boolean ``` ``` operator fun IntRange.contains(value: Short): Boolean ``` ``` operator fun LongRange.contains(value: Short): Boolean ``` ``` operator fun UIntRange.contains(value: UByte): Boolean ``` ``` operator fun ULongRange.contains(value: UByte): Boolean ``` ``` operator fun ULongRange.contains(value: UInt): Boolean ``` ``` operator fun UIntRange.contains(value: ULong): Boolean ``` ``` operator fun UIntRange.contains(value: UShort): Boolean ``` ``` operator fun ULongRange.contains(value: UShort): Boolean ``` Checks if the specified [value](contains#kotlin.ranges%24contains(kotlin.ranges.ClosedRange((kotlin.Int)),%20kotlin.Byte)/value) belongs to this range. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` operator fun <T : Any, R> R.contains(     element: T? ): Boolean where R : ClosedRange<T>, R : Iterable<T> ``` Returns `true` if this iterable range contains the specified [element](contains#kotlin.ranges%24contains(kotlin.ranges.contains.R,%20kotlin.ranges.contains.T?)/element). Always returns `false` if the [element](contains#kotlin.ranges%24contains(kotlin.ranges.contains.R,%20kotlin.ranges.contains.T?)/element) is `null`. kotlin coerceAtLeast coerceAtLeast ============= [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [coerceAtLeast](coerce-at-least) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T ``` Ensures that this value is not less than the specified [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(DayOfWeek.WEDNESDAY.coerceAtLeast(DayOfWeek.MONDAY)) // WEDNESDAY println(DayOfWeek.WEDNESDAY.coerceAtLeast(DayOfWeek.FRIDAY)) // FRIDAY //sampleEnd } ``` **Return** this value if it's greater than or equal to the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue) or the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue) otherwise. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Byte.coerceAtLeast(minimumValue: Byte): Byte ``` ``` fun Short.coerceAtLeast(minimumValue: Short): Short ``` ``` fun Int.coerceAtLeast(minimumValue: Int): Int ``` ``` fun Long.coerceAtLeast(minimumValue: Long): Long ``` ``` fun Float.coerceAtLeast(minimumValue: Float): Float ``` ``` fun Double.coerceAtLeast(minimumValue: Double): Double ``` Ensures that this value is not less than the specified [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.Byte,%20kotlin.Byte)/minimumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10.coerceAtLeast(5)) // 10 println(10.coerceAtLeast(20)) // 20 //sampleEnd } ``` **Return** this value if it's greater than or equal to the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.Byte,%20kotlin.Byte)/minimumValue) or the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.Byte,%20kotlin.Byte)/minimumValue) otherwise. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.coerceAtLeast(minimumValue: UInt): UInt ``` ``` fun ULong.coerceAtLeast(minimumValue: ULong): ULong ``` ``` fun UByte.coerceAtLeast(minimumValue: UByte): UByte ``` ``` fun UShort.coerceAtLeast(minimumValue: UShort): UShort ``` Ensures that this value is not less than the specified [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.UInt,%20kotlin.UInt)/minimumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10u.coerceAtLeast(5u)) // 10 println(10u.coerceAtLeast(20u)) // 20 //sampleEnd } ``` **Return** this value if it's greater than or equal to the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.UInt,%20kotlin.UInt)/minimumValue) or the [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.UInt,%20kotlin.UInt)/minimumValue) otherwise. kotlin last last ==== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <last> **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` fun IntProgression.last(): Int ``` ``` fun LongProgression.last(): Long ``` ``` fun CharProgression.last(): Char ``` ``` fun UIntProgression.last(): UInt ``` ``` fun ULongProgression.last(): ULong ``` 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 progression is empty. kotlin Package kotlin.ranges Package kotlin.ranges ===================== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) [Ranges](../../../../../docs/ranges), Progressions and related top-level and extension functions. Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharProgression](-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) #### [CharRange](-char-range/index) A range of values of type `Char`. ``` class CharRange :      CharProgression,     ClosedRange<Char>,     OpenEndRange<Char> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ClosedFloatingPointRange](-closed-floating-point-range/index) Represents a range of floating point numbers. Extends [ClosedRange](-closed-range/index) interface providing custom operation [lessThanOrEquals](-closed-floating-point-range/less-than-or-equals) for comparing values of range domain type. ``` interface ClosedFloatingPointRange<T : Comparable<T>> :      ClosedRange<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ClosedRange](-closed-range/index) Represents a range of values (for example, numbers or characters) where both the lower and upper bounds are included in the range. See the [Kotlin language documentation](../../../../../docs/ranges) for more information. ``` interface ClosedRange<T : Comparable<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntProgression](-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) #### [IntRange](-int-range/index) A range of values of type `Int`. ``` class IntRange :      IntProgression,     ClosedRange<Int>,     OpenEndRange<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongProgression](-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) #### [LongRange](-long-range/index) A range of values of type `Long`. ``` class LongRange :      LongProgression,     ClosedRange<Long>,     OpenEndRange<Long> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [OpenEndRange](-open-end-range/index) Represents a range of values (for example, numbers or characters) where the upper bound is not included in the range. See the [Kotlin language documentation](../../../../../docs/ranges) for more information. ``` interface OpenEndRange<T : Comparable<T>> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UIntProgression](-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) #### [UIntRange](-u-int-range/index) A range of values of type `UInt`. ``` class UIntRange :      UIntProgression,     ClosedRange<UInt>,     OpenEndRange<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongProgression](-u-long-progression/index) A progression of values of type `ULong`. ``` open class ULongProgression : Iterable<ULong> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongRange](-u-long-range/index) A range of values of type `ULong`. ``` class ULongRange :      ULongProgression,     ClosedRange<ULong>,     OpenEndRange<ULong> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtLeast](coerce-at-least) Ensures that this value is not less than the specified [minimumValue](coerce-at-least#kotlin.ranges%24coerceAtLeast(kotlin.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T ``` ``` fun Byte.coerceAtLeast(minimumValue: Byte): Byte ``` ``` fun Short.coerceAtLeast(minimumValue: Short): Short ``` ``` fun Int.coerceAtLeast(minimumValue: Int): Int ``` ``` fun Long.coerceAtLeast(minimumValue: Long): Long ``` ``` fun Float.coerceAtLeast(minimumValue: Float): Float ``` ``` fun Double.coerceAtLeast(minimumValue: Double): Double ``` ``` fun UInt.coerceAtLeast(minimumValue: UInt): UInt ``` ``` fun ULong.coerceAtLeast(minimumValue: ULong): ULong ``` ``` fun UByte.coerceAtLeast(minimumValue: UByte): UByte ``` ``` fun UShort.coerceAtLeast(minimumValue: UShort): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceAtMost](coerce-at-most) Ensures that this value is not greater than the specified [maximumValue](coerce-at-most#kotlin.ranges%24coerceAtMost(kotlin.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T ``` ``` fun Byte.coerceAtMost(maximumValue: Byte): Byte ``` ``` fun Short.coerceAtMost(maximumValue: Short): Short ``` ``` fun Int.coerceAtMost(maximumValue: Int): Int ``` ``` fun Long.coerceAtMost(maximumValue: Long): Long ``` ``` fun Float.coerceAtMost(maximumValue: Float): Float ``` ``` fun Double.coerceAtMost(maximumValue: Double): Double ``` ``` fun UInt.coerceAtMost(maximumValue: UInt): UInt ``` ``` fun ULong.coerceAtMost(maximumValue: ULong): ULong ``` ``` fun UByte.coerceAtMost(maximumValue: UByte): UByte ``` ``` fun UShort.coerceAtMost(maximumValue: UShort): UShort ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [coerceIn](coerce-in) Ensures that this value lies in the specified range [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` fun <T : Comparable<T>> T.coerceIn(     minimumValue: T?,     maximumValue: T? ): T ``` ``` fun Byte.coerceIn(     minimumValue: Byte,     maximumValue: Byte ): Byte ``` ``` fun Short.coerceIn(     minimumValue: Short,     maximumValue: Short ): Short ``` ``` fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int ``` ``` fun Long.coerceIn(     minimumValue: Long,     maximumValue: Long ): Long ``` ``` fun Float.coerceIn(     minimumValue: Float,     maximumValue: Float ): Float ``` ``` fun Double.coerceIn(     minimumValue: Double,     maximumValue: Double ): Double ``` ``` fun UInt.coerceIn(     minimumValue: UInt,     maximumValue: UInt ): UInt ``` ``` fun ULong.coerceIn(     minimumValue: ULong,     maximumValue: ULong ): ULong ``` ``` fun UByte.coerceIn(     minimumValue: UByte,     maximumValue: UByte ): UByte ``` ``` fun UShort.coerceIn(     minimumValue: UShort,     maximumValue: UShort ): UShort ``` Ensures that this value lies in the specified [range](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 ``` ``` fun Int.coerceIn(range: ClosedRange<Int>): Int ``` ``` fun Long.coerceIn(range: ClosedRange<Long>): Long ``` ``` fun UInt.coerceIn(range: ClosedRange<UInt>): UInt ``` ``` fun ULong.coerceIn(range: ClosedRange<ULong>): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Returns `true` if this range contains the specified [element](contains#kotlin.ranges%24contains(kotlin.ranges.IntRange,%20kotlin.Int?)/element). ``` operator fun IntRange.contains(element: Int?): Boolean ``` ``` operator fun LongRange.contains(element: Long?): Boolean ``` ``` operator fun CharRange.contains(element: Char?): Boolean ``` ``` operator fun UIntRange.contains(element: UInt?): Boolean ``` ``` operator fun ULongRange.contains(element: ULong?): Boolean ``` Checks if the specified [value](contains#kotlin.ranges%24contains(kotlin.ranges.ClosedRange((kotlin.Int)),%20kotlin.Byte)/value) belongs to this range. ``` operator fun ClosedRange<Int>.contains(value: Byte): Boolean ``` ``` operator fun ClosedRange<Long>.contains(value: Byte): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Byte ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Byte ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Byte ): Boolean ``` ``` operator fun OpenEndRange<Int>.contains(value: Byte): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(     value: Byte ): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Byte ): Boolean ``` ``` operator fun IntRange.contains(value: Byte): Boolean ``` ``` operator fun LongRange.contains(value: Byte): Boolean ``` ``` operator fun ClosedRange<Int>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Float): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Float ): Boolean ``` ``` operator fun OpenEndRange<Double>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Long>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Short>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Int ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(value: Int): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(value: Int): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(value: Int): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Int ): Boolean ``` ``` operator fun LongRange.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Long): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(value: Long): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Long ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Long ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Long ): Boolean ``` ``` operator fun OpenEndRange<Int>.contains(value: Long): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(     value: Long ): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Long ): Boolean ``` ``` operator fun IntRange.contains(value: Long): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Short): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Short ): Boolean ``` ``` operator fun OpenEndRange<Int>.contains(     value: Short ): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(     value: Short ): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(     value: Short ): Boolean ``` ``` operator fun IntRange.contains(value: Short): Boolean ``` ``` operator fun LongRange.contains(value: Short): Boolean ``` ``` operator fun UIntRange.contains(value: UByte): Boolean ``` ``` operator fun ULongRange.contains(value: UByte): Boolean ``` ``` operator fun ULongRange.contains(value: UInt): Boolean ``` ``` operator fun UIntRange.contains(value: ULong): Boolean ``` ``` operator fun UIntRange.contains(value: UShort): Boolean ``` ``` operator fun ULongRange.contains(value: UShort): Boolean ``` Returns `true` if this iterable range contains the specified [element](contains#kotlin.ranges%24contains(kotlin.ranges.contains.R,%20kotlin.ranges.contains.T?)/element). ``` operator fun <T : Any, R> R.contains(     element: T? ): Boolean where R : ClosedRange<T>, R : Iterable<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [downTo](down-to) Returns a progression from this value down to the specified [to](down-to#kotlin.ranges%24downTo(kotlin.Int,%20kotlin.Byte)/to) value with the step -1. ``` infix fun Int.downTo(to: Byte): IntProgression ``` ``` infix fun Long.downTo(to: Byte): LongProgression ``` ``` infix fun Byte.downTo(to: Byte): IntProgression ``` ``` infix fun Short.downTo(to: Byte): IntProgression ``` ``` infix fun Char.downTo(to: Char): CharProgression ``` ``` infix fun Int.downTo(to: Int): IntProgression ``` ``` infix fun Long.downTo(to: Int): LongProgression ``` ``` infix fun Byte.downTo(to: Int): IntProgression ``` ``` infix fun Short.downTo(to: Int): IntProgression ``` ``` infix fun Int.downTo(to: Long): LongProgression ``` ``` infix fun Long.downTo(to: Long): LongProgression ``` ``` infix fun Byte.downTo(to: Long): LongProgression ``` ``` infix fun Short.downTo(to: Long): LongProgression ``` ``` infix fun Int.downTo(to: Short): IntProgression ``` ``` infix fun Long.downTo(to: Short): LongProgression ``` ``` infix fun Byte.downTo(to: Short): IntProgression ``` ``` infix fun Short.downTo(to: Short): IntProgression ``` ``` infix fun UByte.downTo(to: UByte): UIntProgression ``` ``` infix fun UInt.downTo(to: UInt): UIntProgression ``` ``` infix fun ULong.downTo(to: ULong): ULongProgression ``` ``` infix fun UShort.downTo(to: UShort): UIntProgression ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### <first> Returns the first element. ``` fun IntProgression.first(): Int ``` ``` fun LongProgression.first(): Long ``` ``` fun CharProgression.first(): Char ``` ``` fun UIntProgression.first(): UInt ``` ``` fun ULongProgression.first(): ULong ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [firstOrNull](first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun IntProgression.firstOrNull(): Int? ``` ``` fun LongProgression.firstOrNull(): Long? ``` ``` fun CharProgression.firstOrNull(): Char? ``` ``` fun UIntProgression.firstOrNull(): UInt? ``` ``` fun ULongProgression.firstOrNull(): ULong? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### <last> Returns the last element. ``` fun IntProgression.last(): Int ``` ``` fun LongProgression.last(): Long ``` ``` fun CharProgression.last(): Char ``` ``` fun UIntProgression.last(): UInt ``` ``` fun ULongProgression.last(): ULong ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun IntProgression.lastOrNull(): Int? ``` ``` fun LongProgression.lastOrNull(): Long? ``` ``` fun CharProgression.lastOrNull(): Char? ``` ``` fun UIntProgression.lastOrNull(): UInt? ``` ``` fun ULongProgression.lastOrNull(): ULong? ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <random> Returns a random element from this range. ``` fun IntRange.random(): Int ``` ``` fun LongRange.random(): Long ``` ``` fun CharRange.random(): Char ``` ``` fun UIntRange.random(): UInt ``` ``` fun ULongRange.random(): ULong ``` Returns a random element from this range using the specified source of randomness. ``` fun IntRange.random(random: Random): Int ``` ``` fun LongRange.random(random: Random): Long ``` ``` fun CharRange.random(random: Random): Char ``` ``` fun UIntRange.random(random: Random): UInt ``` ``` fun ULongRange.random(random: Random): ULong ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun IntRange.randomOrNull(): Int? ``` ``` fun LongRange.randomOrNull(): Long? ``` ``` fun CharRange.randomOrNull(): Char? ``` ``` fun UIntRange.randomOrNull(): UInt? ``` ``` fun ULongRange.randomOrNull(): ULong? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun IntRange.randomOrNull(random: Random): Int? ``` ``` fun LongRange.randomOrNull(random: Random): Long? ``` ``` fun CharRange.randomOrNull(random: Random): Char? ``` ``` fun UIntRange.randomOrNull(random: Random): UInt? ``` ``` fun ULongRange.randomOrNull(random: Random): ULong? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](range-to) Creates a range from this [Comparable](../kotlin/-comparable/index#kotlin.Comparable) value to the specified [that](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> ``` Creates a range from this [Double](../kotlin/-double/index#kotlin.Double) value to the specified [that](range-to#kotlin.ranges%24rangeTo(kotlin.Double,%20kotlin.Double)/that) value. ``` operator fun Double.rangeTo(     that: Double ): ClosedFloatingPointRange<Double> ``` Creates a range from this [Float](../kotlin/-float/index#kotlin.Float) value to the specified [that](range-to#kotlin.ranges%24rangeTo(kotlin.Float,%20kotlin.Float)/that) value. ``` operator fun Float.rangeTo(     that: Float ): ClosedFloatingPointRange<Float> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [rangeUntil](range-until) Creates an open-ended range from this [Comparable](../kotlin/-comparable/index#kotlin.Comparable) value to the specified [that](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> ``` Creates an open-ended range from this [Double](../kotlin/-double/index#kotlin.Double) value to the specified [that](range-until#kotlin.ranges%24rangeUntil(kotlin.Double,%20kotlin.Double)/that) value. ``` operator fun Double.rangeUntil(     that: Double ): OpenEndRange<Double> ``` Creates an open-ended range from this [Float](../kotlin/-float/index#kotlin.Float) value to the specified [that](range-until#kotlin.ranges%24rangeUntil(kotlin.Float,%20kotlin.Float)/that) value. ``` operator fun Float.rangeUntil(     that: Float ): OpenEndRange<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reversed> Returns a progression that goes over the same range in the opposite direction with the same step. ``` fun IntProgression.reversed(): IntProgression ``` ``` fun LongProgression.reversed(): LongProgression ``` ``` fun CharProgression.reversed(): CharProgression ``` ``` fun UIntProgression.reversed(): UIntProgression ``` ``` fun ULongProgression.reversed(): ULongProgression ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> Returns a progression that goes over the same range with the given step. ``` infix fun IntProgression.step(step: Int): IntProgression ``` ``` infix fun LongProgression.step(step: Long): LongProgression ``` ``` infix fun CharProgression.step(step: Int): CharProgression ``` ``` infix fun UIntProgression.step(step: Int): UIntProgression ``` ``` infix fun ULongProgression.step(step: Long): ULongProgression ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <until> Returns a range from this value up to but excluding the specified [to](until#kotlin.ranges%24until(kotlin.Int,%20kotlin.Byte)/to) value. ``` infix fun Int.until(to: Byte): IntRange ``` ``` infix fun Long.until(to: Byte): LongRange ``` ``` infix fun Byte.until(to: Byte): IntRange ``` ``` infix fun Short.until(to: Byte): IntRange ``` ``` infix fun Char.until(to: Char): CharRange ``` ``` infix fun Int.until(to: Int): IntRange ``` ``` infix fun Long.until(to: Int): LongRange ``` ``` infix fun Byte.until(to: Int): IntRange ``` ``` infix fun Short.until(to: Int): IntRange ``` ``` infix fun Int.until(to: Long): LongRange ``` ``` infix fun Long.until(to: Long): LongRange ``` ``` infix fun Byte.until(to: Long): LongRange ``` ``` infix fun Short.until(to: Long): LongRange ``` ``` infix fun Int.until(to: Short): IntRange ``` ``` infix fun Long.until(to: Short): LongRange ``` ``` infix fun Byte.until(to: Short): IntRange ``` ``` infix fun Short.until(to: Short): IntRange ``` ``` infix fun UByte.until(to: UByte): UIntRange ``` ``` infix fun UInt.until(to: UInt): UIntRange ``` ``` infix fun ULong.until(to: ULong): ULongRange ``` ``` infix fun UShort.until(to: UShort): UIntRange ```
programming_docs
kotlin lastOrNull lastOrNull ========== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [lastOrNull](last-or-null) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` fun IntProgression.lastOrNull(): Int? ``` ``` fun LongProgression.lastOrNull(): Long? ``` ``` fun CharProgression.lastOrNull(): Char? ``` ``` fun UIntProgression.lastOrNull(): UInt? ``` ``` fun ULongProgression.lastOrNull(): ULong? ``` Returns the last element, or `null` if the progression 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 rangeTo rangeTo ======= [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T : Comparable<T>> T.rangeTo(     that: T ): ClosedRange<T> ``` Creates a range from this [Comparable](../kotlin/-comparable/index#kotlin.Comparable) value to the specified [that](range-to#kotlin.ranges%24rangeTo(kotlin.ranges.rangeTo.T,%20kotlin.ranges.rangeTo.T)/that) value. This value needs to be smaller than or equal to [that](range-to#kotlin.ranges%24rangeTo(kotlin.ranges.rangeTo.T,%20kotlin.ranges.rangeTo.T)/that) value, otherwise the returned range will be empty. ``` import java.sql.Date import kotlin.test.assertFalse import kotlin.test.assertTrue fun main(args: Array<String>) { //sampleStart val start = Date.valueOf("2017-01-01") val end = Date.valueOf("2017-12-31") val range = start..end println(range) // 2017-01-01..2017-12-31 println("Date.valueOf(\"2017-05-27\") in range is ${Date.valueOf("2017-05-27") in range}") // true println("Date.valueOf(\"2018-01-01\") in range is ${Date.valueOf("2018-01-01") in range}") // false println("Date.valueOf(\"2018-01-01\") !in range is ${Date.valueOf("2018-01-01") !in range}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun Double.rangeTo(     that: Double ): ClosedFloatingPointRange<Double> ``` Creates a range from this [Double](../kotlin/-double/index#kotlin.Double) value to the specified [that](range-to#kotlin.ranges%24rangeTo(kotlin.Double,%20kotlin.Double)/that) value. Numbers are compared with the ends of this range according to IEEE-754. ``` import java.sql.Date import kotlin.test.assertFalse import kotlin.test.assertTrue fun main(args: Array<String>) { //sampleStart val range = 1.0..100.0 println(range) // 1.0..100.0 println("3.14 in range is ${3.14 in range}") // true println("100.1 in range is ${100.1 in range}") // false //sampleEnd } ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun Float.rangeTo(     that: Float ): ClosedFloatingPointRange<Float> ``` Creates a range from this [Float](../kotlin/-float/index#kotlin.Float) value to the specified [that](range-to#kotlin.ranges%24rangeTo(kotlin.Float,%20kotlin.Float)/that) value. Numbers are compared with the ends of this range according to IEEE-754. ``` import java.sql.Date import kotlin.test.assertFalse import kotlin.test.assertTrue fun main(args: Array<String>) { //sampleStart val range = 1f..100f println(range) // 1.0..100.0 println("3.14f in range is ${3.14f in range}") // true println("100.1f in range is ${100.1f in range}") // false //sampleEnd } ``` kotlin coerceIn coerceIn ======== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [coerceIn](coerce-in) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> T.coerceIn(     minimumValue: T?,     maximumValue: T? ): T ``` Ensures that this value lies in the specified range [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart val workingDays = DayOfWeek.MONDAY..DayOfWeek.FRIDAY println(DayOfWeek.WEDNESDAY.coerceIn(workingDays)) // WEDNESDAY println(DayOfWeek.SATURDAY.coerceIn(workingDays)) // FRIDAY println(DayOfWeek.FRIDAY.coerceIn(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)) // SATURDAY //sampleEnd } ``` **Return** this value if it's in the range, or [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue) if this value is less than [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue), or [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue) if this value is greater than [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Byte.coerceIn(     minimumValue: Byte,     maximumValue: Byte ): Byte ``` ``` fun Short.coerceIn(     minimumValue: Short,     maximumValue: Short ): Short ``` ``` fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int ``` ``` fun Long.coerceIn(     minimumValue: Long,     maximumValue: Long ): Long ``` ``` fun Float.coerceIn(     minimumValue: Float,     maximumValue: Float ): Float ``` ``` fun Double.coerceIn(     minimumValue: Double,     maximumValue: Double ): Double ``` Ensures that this value lies in the specified range [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/minimumValue)..[maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10.coerceIn(1, 100)) // 10 println(10.coerceIn(1..100)) // 10 println(0.coerceIn(1, 100)) // 1 println(500.coerceIn(1, 100)) // 100 // 10.coerceIn(100, 0) // will fail with IllegalArgumentException //sampleEnd } ``` **Return** this value if it's in the range, or [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/minimumValue) if this value is less than [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/minimumValue), or [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/maximumValue) if this value is greater than [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/maximumValue). **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T : Comparable<T>> T.coerceIn(     range: ClosedFloatingPointRange<T> ): T ``` Ensures that this value lies in the specified [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.ClosedFloatingPointRange((kotlin.ranges.coerceIn.T)))/range). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10.1.coerceIn(1.0..10.0)) // 10.0 println(9.9.coerceIn(1.0..10.0)) // 9.9 // 9.9.coerceIn(1.0..Double.NaN) // will fail with IllegalArgumentException //sampleEnd } ``` **Return** this value if it's in the [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.ClosedFloatingPointRange((kotlin.ranges.coerceIn.T)))/range), or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T ``` Ensures that this value lies in the specified [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.ClosedRange((kotlin.ranges.coerceIn.T)))/range). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart val workingDays = DayOfWeek.MONDAY..DayOfWeek.FRIDAY println(DayOfWeek.WEDNESDAY.coerceIn(workingDays)) // WEDNESDAY println(DayOfWeek.SATURDAY.coerceIn(workingDays)) // FRIDAY println(DayOfWeek.FRIDAY.coerceIn(DayOfWeek.SATURDAY, DayOfWeek.SUNDAY)) // SATURDAY //sampleEnd } ``` **Return** this value if it's in the [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.ClosedRange((kotlin.ranges.coerceIn.T)))/range), or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Int.coerceIn(range: ClosedRange<Int>): Int ``` ``` fun Long.coerceIn(range: ClosedRange<Long>): Long ``` Ensures that this value lies in the specified [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.Int,%20kotlin.ranges.ClosedRange((kotlin.Int)))/range). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10.coerceIn(1, 100)) // 10 println(10.coerceIn(1..100)) // 10 println(0.coerceIn(1, 100)) // 1 println(500.coerceIn(1, 100)) // 100 // 10.coerceIn(100, 0) // will fail with IllegalArgumentException //sampleEnd } ``` **Return** this value if it's in the [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.Int,%20kotlin.ranges.ClosedRange((kotlin.Int)))/range), or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.coerceIn(     minimumValue: UInt,     maximumValue: UInt ): UInt ``` ``` fun ULong.coerceIn(     minimumValue: ULong,     maximumValue: ULong ): ULong ``` ``` fun UByte.coerceIn(     minimumValue: UByte,     maximumValue: UByte ): UByte ``` ``` fun UShort.coerceIn(     minimumValue: UShort,     maximumValue: UShort ): UShort ``` Ensures that this value lies in the specified range [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/minimumValue)..[maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/maximumValue). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10u.coerceIn(1u, 100u)) // 10 println(10u.coerceIn(1u..100u)) // 10 println(0u.coerceIn(1u, 100u)) // 1 println(500u.coerceIn(1u, 100u)) // 100 // 10u.coerceIn(100u, 0u) // will fail with IllegalArgumentException //sampleEnd } ``` **Return** this value if it's in the range, or [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/minimumValue) if this value is less than [minimumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/minimumValue), or [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/maximumValue) if this value is greater than [maximumValue](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.UInt,%20kotlin.UInt)/maximumValue). **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.coerceIn(range: ClosedRange<UInt>): UInt ``` ``` fun ULong.coerceIn(range: ClosedRange<ULong>): ULong ``` Ensures that this value lies in the specified [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.ranges.ClosedRange((kotlin.UInt)))/range). ``` import java.time.DayOfWeek import kotlin.test.assertFailsWith fun main(args: Array<String>) { //sampleStart println(10u.coerceIn(1u, 100u)) // 10 println(10u.coerceIn(1u..100u)) // 10 println(0u.coerceIn(1u, 100u)) // 1 println(500u.coerceIn(1u, 100u)) // 100 // 10u.coerceIn(100u, 0u) // will fail with IllegalArgumentException //sampleEnd } ``` **Return** this value if it's in the [range](coerce-in#kotlin.ranges%24coerceIn(kotlin.UInt,%20kotlin.ranges.ClosedRange((kotlin.UInt)))/range), or `range.start` if this value is less than `range.start`, or `range.endInclusive` if this value is greater than `range.endInclusive`. kotlin firstOrNull firstOrNull =========== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [firstOrNull](first-or-null) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` fun IntProgression.firstOrNull(): Int? ``` ``` fun LongProgression.firstOrNull(): Long? ``` ``` fun CharProgression.firstOrNull(): Char? ``` ``` fun UIntProgression.firstOrNull(): UInt? ``` ``` fun ULongProgression.firstOrNull(): ULong? ``` Returns the first element, or `null` if the progression is empty. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun <T : Comparable<T>> T.rangeUntil(     that: T ): OpenEndRange<T> ``` Creates an open-ended range from this [Comparable](../kotlin/-comparable/index#kotlin.Comparable) value to the specified [that](range-until#kotlin.ranges%24rangeUntil(kotlin.ranges.rangeUntil.T,%20kotlin.ranges.rangeUntil.T)/that) value. This value needs to be smaller than [that](range-until#kotlin.ranges%24rangeUntil(kotlin.ranges.rangeUntil.T,%20kotlin.ranges.rangeUntil.T)/that) value, otherwise the returned range will be empty. ``` import java.sql.Date import kotlin.test.assertFalse import kotlin.test.assertTrue fun main(args: Array<String>) { //sampleStart val start = Date.valueOf("2017-01-01") val end = Date.valueOf("2017-12-31") val range = start..end println(range) // 2017-01-01..2017-12-31 println("Date.valueOf(\"2017-05-27\") in range is ${Date.valueOf("2017-05-27") in range}") // true println("Date.valueOf(\"2018-01-01\") in range is ${Date.valueOf("2018-01-01") in range}") // false println("Date.valueOf(\"2018-01-01\") !in range is ${Date.valueOf("2018-01-01") !in range}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun Double.rangeUntil(     that: Double ): OpenEndRange<Double> ``` Creates an open-ended range from this [Double](../kotlin/-double/index#kotlin.Double) value to the specified [that](range-until#kotlin.ranges%24rangeUntil(kotlin.Double,%20kotlin.Double)/that) value. Numbers are compared with the ends of this range according to IEEE-754. **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun Float.rangeUntil(     that: Float ): OpenEndRange<Float> ``` Creates an open-ended range from this [Float](../kotlin/-float/index#kotlin.Float) value to the specified [that](range-until#kotlin.ranges%24rangeUntil(kotlin.Float,%20kotlin.Float)/that) value. Numbers are compared with the ends of this range according to IEEE-754. kotlin randomOrNull randomOrNull ============ [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [randomOrNull](random-or-null) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun IntRange.randomOrNull(): Int? ``` ``` fun LongRange.randomOrNull(): Long? ``` ``` fun CharRange.randomOrNull(): Char? ``` ``` fun UIntRange.randomOrNull(): UInt? ``` ``` fun ULongRange.randomOrNull(): ULong? ``` Returns a random element from this range, or `null` if this range is empty. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun IntRange.randomOrNull(random: Random): Int? ``` ``` fun LongRange.randomOrNull(random: Random): Long? ``` ``` fun CharRange.randomOrNull(random: Random): Char? ``` ``` fun UIntRange.randomOrNull(random: Random): UInt? ``` ``` fun ULongRange.randomOrNull(random: Random): ULong? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. kotlin random random ====== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <random> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun IntRange.random(): Int ``` ``` fun LongRange.random(): Long ``` ``` fun CharRange.random(): Char ``` ``` fun UIntRange.random(): UInt ``` ``` fun ULongRange.random(): ULong ``` Returns a random element from this range. Exceptions ---------- `IllegalArgumentException` - if this range is empty. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun IntRange.random(random: Random): Int ``` ``` fun LongRange.random(random: Random): Long ``` ``` fun CharRange.random(random: Random): Char ``` ``` fun UIntRange.random(random: Random): UInt ``` ``` fun ULongRange.random(random: Random): ULong ``` Returns a random element from this range using the specified source of randomness. Exceptions ---------- `IllegalArgumentException` - if this range is empty. kotlin reversed reversed ======== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <reversed> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun IntProgression.reversed(): IntProgression ``` ``` fun LongProgression.reversed(): LongProgression ``` ``` fun CharProgression.reversed(): CharProgression ``` ``` fun UIntProgression.reversed(): UIntProgression ``` ``` fun ULongProgression.reversed(): ULongProgression ``` Returns a progression that goes over the same range in the opposite direction with the same step. kotlin downTo downTo ====== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / [downTo](down-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun Int.downTo(to: Byte): IntProgression ``` ``` infix fun Long.downTo(to: Byte): LongProgression ``` ``` infix fun Byte.downTo(to: Byte): IntProgression ``` ``` infix fun Short.downTo(to: Byte): IntProgression ``` ``` infix fun Char.downTo(to: Char): CharProgression ``` ``` infix fun Int.downTo(to: Int): IntProgression ``` ``` infix fun Long.downTo(to: Int): LongProgression ``` ``` infix fun Byte.downTo(to: Int): IntProgression ``` ``` infix fun Short.downTo(to: Int): IntProgression ``` ``` infix fun Int.downTo(to: Long): LongProgression ``` ``` infix fun Long.downTo(to: Long): LongProgression ``` ``` infix fun Byte.downTo(to: Long): LongProgression ``` ``` infix fun Short.downTo(to: Long): LongProgression ``` ``` infix fun Int.downTo(to: Short): IntProgression ``` ``` infix fun Long.downTo(to: Short): LongProgression ``` ``` infix fun Byte.downTo(to: Short): IntProgression ``` ``` infix fun Short.downTo(to: Short): IntProgression ``` ``` infix fun UByte.downTo(to: UByte): UIntProgression ``` ``` infix fun UInt.downTo(to: UInt): UIntProgression ``` ``` infix fun ULong.downTo(to: ULong): ULongProgression ``` ``` infix fun UShort.downTo(to: UShort): UIntProgression ``` Returns a progression from this value down to the specified [to](down-to#kotlin.ranges%24downTo(kotlin.Int,%20kotlin.Byte)/to) value with the step -1. The [to](down-to#kotlin.ranges%24downTo(kotlin.Int,%20kotlin.Byte)/to) value should be less than or equal to `this` value. If the [to](down-to#kotlin.ranges%24downTo(kotlin.Int,%20kotlin.Byte)/to) value is greater than `this` value the returned progression is empty.
programming_docs
kotlin step step ==== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun IntProgression.step(step: Int): IntProgression ``` ``` infix fun LongProgression.step(step: Long): LongProgression ``` ``` infix fun CharProgression.step(step: Int): CharProgression ``` ``` infix fun UIntProgression.step(step: Int): UIntProgression ``` ``` infix fun ULongProgression.step(step: Long): ULongProgression ``` Returns a progression that goes over the same range with the given step. kotlin first first ===== [kotlin-stdlib](../../../../../index) / [kotlin.ranges](index) / <first> **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` fun IntProgression.first(): Int ``` ``` fun LongProgression.first(): Long ``` ``` fun CharProgression.first(): Char ``` ``` fun UIntProgression.first(): UInt ``` ``` fun ULongProgression.first(): ULong ``` Returns the first element. Exceptions ---------- `NoSuchElementException` - if the progression is empty. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(value: ULong): Boolean ``` Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the [start](../-open-end-range/start) bound and strictly less than the [endExclusive](../-open-end-range/end-exclusive) bound. kotlin ULongRange ULongRange ========== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` class ULongRange :      ULongProgression,     ClosedRange<ULong>,     OpenEndRange<ULong> ``` A range of values of type `ULong`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A range of values of type `ULong`. ``` ULongRange(start: ULong, endInclusive: ULong) ``` Properties ---------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` val endExclusive: ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) ``` val endInclusive: ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` val start: ULong ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` fun contains(value: ULong): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isEmpty](is-empty) Checks if the range is empty. ``` 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. ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EMPTY](-e-m-p-t-y) An empty range of values of type ULong. ``` val EMPTY: ULongRange ``` 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) #### [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.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.5), JS (1.5), Native (1.5) #### [contains](../contains) Returns `true` if this range contains the specified [element](../contains#kotlin.ranges%24contains(kotlin.ranges.ULongRange,%20kotlin.ULong?)/element). ``` operator fun ULongRange.contains(element: ULong?): Boolean ``` Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.ULongRange,%20kotlin.UByte)/value) belongs to this range. ``` operator fun ULongRange.contains(value: UByte): Boolean ``` ``` operator fun ULongRange.contains(value: UInt): Boolean ``` ``` operator fun ULongRange.contains(value: UShort): Boolean ``` **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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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 ``` **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 ``` **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? ``` **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.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 <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` **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.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 <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [random](../random) Returns a random element from this range. ``` fun ULongRange.random(): ULong ``` Returns a random element from this range using the specified source of randomness. ``` fun ULongRange.random(random: Random): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [randomOrNull](../random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun ULongRange.randomOrNull(): ULong? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun ULongRange.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.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) #### [requireNoNulls](../../kotlin.collections/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.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, 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](../../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 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](../../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) #### [sorted](../../kotlin.collections/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](../../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) #### [sortedDescending](../../kotlin.collections/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](../../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.5), JS (1.5), Native (1.5) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun ULongProgression.step(step: Long): ULongProgression ``` **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.5), JS (1.5), Native (1.5) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<ULong>.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.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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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 start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val start: ULong ``` The minimum value in the range. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](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 EMPTY EMPTY ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / [EMPTY](-e-m-p-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val EMPTY: ULongRange ``` An empty range of values of type ULong. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](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 endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi val endExclusive: ULong ``` **Deprecated:** Can throw an exception when it's impossible to represent the value with ULong type, for example, when the range includes MAX\_VALUE. It's recommended to use 'endInclusive' property that doesn't throw. The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](../-open-end-range/index#T). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ULongRange(start: ULong, endInclusive: ULong) ``` A range of values of type `ULong`. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](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. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` Checks if the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val endInclusive: ULong ``` kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val last: UInt ``` The last element in the progression. kotlin UIntProgression UIntProgression =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` open class UIntProgression : Iterable<UInt> ``` A progression of values of type `UInt`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> The first element in the progression. ``` val first: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> The last element in the progression. ``` val last: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> The step of the progression. ``` val step: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks if the progression is empty. ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` fun iterator(): Iterator<UInt> ``` **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 ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fromClosedRange](from-closed-range) Creates UIntProgression within the specified bounds of a closed range. ``` fun fromClosedRange(     rangeStart: UInt,     rangeEnd: UInt,     step: Int ): UIntProgression ``` 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) #### [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.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) #### [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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [first](../first) Returns the first element. ``` fun UIntProgression.first(): UInt ``` **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.7), JS (1.7), Native (1.7) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun UIntProgression.firstOrNull(): UInt? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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.7), JS (1.7), Native (1.7) #### [last](../last) Returns the last element. ``` fun UIntProgression.last(): UInt ``` **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 ``` **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 ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun UIntProgression.lastOrNull(): UInt? ``` **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? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **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) #### [requireNoNulls](../../kotlin.collections/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.5), JS (1.5), Native (1.5) #### [reversed](../reversed) Returns a progression that goes over the same range in the opposite direction with the same step. ``` fun UIntProgression.reversed(): UIntProgression ``` **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, 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](../../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 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](../../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) #### [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.5), JS (1.5), Native (1.5) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun UIntProgression.step(step: Int): UIntProgression ``` **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.5), JS (1.5), Native (1.5) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<UInt>.sum(): UInt ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UIntRange](../-u-int-range/index) A range of values of type `UInt`. ``` class UIntRange :      UIntProgression,     ClosedRange<UInt>,     OpenEndRange<UInt> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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 iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun iterator(): Iterator<UInt> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](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 fromClosedRange fromClosedRange =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / [fromClosedRange](from-closed-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun fromClosedRange(     rangeStart: UInt,     rangeEnd: UInt,     step: Int ): UIntProgression ``` Creates UIntProgression within the specified bounds of a closed range. The progression starts with the [rangeStart](from-closed-range#kotlin.ranges.UIntProgression.Companion%24fromClosedRange(kotlin.UInt,%20kotlin.UInt,%20kotlin.Int)/rangeStart) value and goes toward the [rangeEnd](from-closed-range#kotlin.ranges.UIntProgression.Companion%24fromClosedRange(kotlin.UInt,%20kotlin.UInt,%20kotlin.Int)/rangeEnd) value not excluding it, with the specified [step](from-closed-range#kotlin.ranges.UIntProgression.Companion%24fromClosedRange(kotlin.UInt,%20kotlin.UInt,%20kotlin.Int)/step). In order to go backwards the [step](from-closed-range#kotlin.ranges.UIntProgression.Companion%24fromClosedRange(kotlin.UInt,%20kotlin.UInt,%20kotlin.Int)/step) must be negative. [step](from-closed-range#kotlin.ranges.UIntProgression.Companion%24fromClosedRange(kotlin.UInt,%20kotlin.UInt,%20kotlin.Int)/step) must be greater than `Int.MIN_VALUE` and not equal to zero. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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. kotlin step step ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val step: Int ``` The step of the progression. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks if the progression is empty. Progression with a positive step is empty if its first element is greater than the last element. Progression with a negative step is empty if its first element is less than the last element. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntProgression](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: UInt ``` The first element in the progression. kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val last: ULong ``` The last element in the progression. kotlin ULongProgression ULongProgression ================ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` open class ULongProgression : Iterable<ULong> ``` A progression of values of type `ULong`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> The first element in the progression. ``` val first: ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> The last element in the progression. ``` val last: ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> The step of the progression. ``` val step: Long ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks if the progression is empty. ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` fun iterator(): Iterator<ULong> ``` **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 ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fromClosedRange](from-closed-range) Creates ULongProgression within the specified bounds of a closed range. ``` fun fromClosedRange(     rangeStart: ULong,     rangeEnd: ULong,     step: Long ): ULongProgression ``` 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) #### [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.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) #### [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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [first](../first) Returns the first element. ``` fun ULongProgression.first(): ULong ``` **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.7), JS (1.7), Native (1.7) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun ULongProgression.firstOrNull(): ULong? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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.7), JS (1.7), Native (1.7) #### [last](../last) Returns the last element. ``` fun ULongProgression.last(): ULong ``` **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 ``` **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 ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun ULongProgression.lastOrNull(): ULong? ``` **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? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **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) #### [requireNoNulls](../../kotlin.collections/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.5), JS (1.5), Native (1.5) #### [reversed](../reversed) Returns a progression that goes over the same range in the opposite direction with the same step. ``` fun ULongProgression.reversed(): ULongProgression ``` **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, 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](../../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 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](../../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) #### [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.5), JS (1.5), Native (1.5) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun ULongProgression.step(step: Long): ULongProgression ``` **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.5), JS (1.5), Native (1.5) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<ULong>.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.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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongRange](../-u-long-range/index) A range of values of type `ULong`. ``` class ULongRange :      ULongProgression,     ClosedRange<ULong>,     OpenEndRange<ULong> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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 iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun iterator(): Iterator<ULong> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](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 fromClosedRange fromClosedRange =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / [fromClosedRange](from-closed-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun fromClosedRange(     rangeStart: ULong,     rangeEnd: ULong,     step: Long ): ULongProgression ``` Creates ULongProgression within the specified bounds of a closed range. The progression starts with the [rangeStart](from-closed-range#kotlin.ranges.ULongProgression.Companion%24fromClosedRange(kotlin.ULong,%20kotlin.ULong,%20kotlin.Long)/rangeStart) value and goes toward the [rangeEnd](from-closed-range#kotlin.ranges.ULongProgression.Companion%24fromClosedRange(kotlin.ULong,%20kotlin.ULong,%20kotlin.Long)/rangeEnd) value not excluding it, with the specified [step](from-closed-range#kotlin.ranges.ULongProgression.Companion%24fromClosedRange(kotlin.ULong,%20kotlin.ULong,%20kotlin.Long)/step). In order to go backwards the [step](from-closed-range#kotlin.ranges.ULongProgression.Companion%24fromClosedRange(kotlin.ULong,%20kotlin.ULong,%20kotlin.Long)/step) must be negative. [step](from-closed-range#kotlin.ranges.ULongProgression.Companion%24fromClosedRange(kotlin.ULong,%20kotlin.ULong,%20kotlin.Long)/step) must be greater than `Long.MIN_VALUE` and not equal to zero. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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. kotlin step step ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val step: Long ``` The step of the progression. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks if the progression is empty. Progression with a positive step is empty if its first element is greater than the last element. Progression with a negative step is empty if its first element is less than the last element. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ULongProgression](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: ULong ``` The first element in the progression. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedFloatingPointRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun contains(value: T): Boolean ``` kotlin lessThanOrEquals lessThanOrEquals ================ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedFloatingPointRange](index) / [lessThanOrEquals](less-than-or-equals) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun lessThanOrEquals(a: T, b: T): Boolean ``` Compares two values of range domain type and returns true if first is less than or equal to second. kotlin ClosedFloatingPointRange ClosedFloatingPointRange ======================== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedFloatingPointRange](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` interface ClosedFloatingPointRange<T : Comparable<T>> :      ClosedRange<T> ``` Represents a range of floating point numbers. Extends [ClosedRange](../-closed-range/index) interface providing custom operation [lessThanOrEquals](less-than-or-equals) for comparing values of range domain type. This interface is implemented by floating point ranges returned by [Float.rangeTo](../range-to) and [Double.rangeTo](../range-to) operators to achieve IEEE-754 comparison order instead of total order of floating point numbers. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> ``` open fun contains(value: T): 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) #### [lessThanOrEquals](less-than-or-equals) Compares two values of range domain type and returns true if first is less than or equal to second. ``` abstract fun lessThanOrEquals(a: T, b: T): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedFloatingPointRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val last: Char ``` The last element in the progression. kotlin CharProgression CharProgression =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open class CharProgression : Iterable<Char> ``` A progression of values of type `Char`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> The first element in the progression. ``` val first: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> The last element in the progression. ``` val last: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> The step of the progression. ``` val step: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks if the progression is empty. ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` open fun iterator(): CharIterator ``` **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 ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fromClosedRange](from-closed-range) Creates CharProgression within the specified bounds of a closed range. ``` fun fromClosedRange(     rangeStart: Char,     rangeEnd: Char,     step: Int ): CharProgression ``` 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) #### [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.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) #### [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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [first](../first) Returns the first element. ``` fun CharProgression.first(): Char ``` **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.7), JS (1.7), Native (1.7) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun CharProgression.firstOrNull(): Char? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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.7), JS (1.7), Native (1.7) #### [last](../last) Returns the last element. ``` fun CharProgression.last(): Char ``` **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 ``` **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 ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun CharProgression.lastOrNull(): Char? ``` **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? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **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) #### [requireNoNulls](../../kotlin.collections/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 progression that goes over the same range in the opposite direction with the same step. ``` fun CharProgression.reversed(): CharProgression ``` **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, 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](../../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 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](../../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) #### [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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun CharProgression.step(step: Int): CharProgression ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharRange](../-char-range/index) A range of values of type `Char`. ``` class CharRange :      CharProgression,     ClosedRange<Char>,     OpenEndRange<Char> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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 iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun iterator(): CharIterator ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](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 fromClosedRange fromClosedRange =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / [fromClosedRange](from-closed-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun fromClosedRange(     rangeStart: Char,     rangeEnd: Char,     step: Int ): CharProgression ``` Creates CharProgression within the specified bounds of a closed range. The progression starts with the [rangeStart](from-closed-range#kotlin.ranges.CharProgression.Companion%24fromClosedRange(kotlin.Char,%20kotlin.Char,%20kotlin.Int)/rangeStart) value and goes toward the [rangeEnd](from-closed-range#kotlin.ranges.CharProgression.Companion%24fromClosedRange(kotlin.Char,%20kotlin.Char,%20kotlin.Int)/rangeEnd) value not excluding it, with the specified [step](from-closed-range#kotlin.ranges.CharProgression.Companion%24fromClosedRange(kotlin.Char,%20kotlin.Char,%20kotlin.Int)/step). In order to go backwards the [step](from-closed-range#kotlin.ranges.CharProgression.Companion%24fromClosedRange(kotlin.Char,%20kotlin.Char,%20kotlin.Int)/step) must be negative. [step](from-closed-range#kotlin.ranges.CharProgression.Companion%24fromClosedRange(kotlin.Char,%20kotlin.Char,%20kotlin.Int)/step) must be greater than `Int.MIN_VALUE` and not equal to zero. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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. kotlin step step ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val step: Int ``` The step of the progression. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks if the progression is empty. Progression with a positive step is empty if its first element is greater than the last element. Progression with a negative step is empty if its first element is less than the last element. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharProgression](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: Char ``` The first element in the progression. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [OpenEndRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun contains(value: T): Boolean ``` Checks whether the specified [value](contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the <start> bound and strictly less than the [endExclusive](end-exclusive) bound. kotlin OpenEndRange OpenEndRange ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [OpenEndRange](index) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi interface OpenEndRange<T : Comparable<T>> ``` Represents a range of values (for example, numbers or characters) where the upper bound is not included in the range. See the [Kotlin language documentation](../../../../../../docs/ranges) for more information. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` abstract val endExclusive: T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` abstract val start: T ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` open operator fun contains(value: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks whether the range is empty. ``` open fun isEmpty(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [contains](../contains) Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.OpenEndRange((kotlin.Int)),%20kotlin.Byte)/value) belongs to this range. ``` operator fun OpenEndRange<Int>.contains(value: Byte): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(     value: Byte ): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Byte ): Boolean ``` ``` operator fun OpenEndRange<Double>.contains(     value: Float ): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(value: Int): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(value: Int): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Int ): Boolean ``` ``` operator fun OpenEndRange<Int>.contains(value: Long): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(     value: Long ): Boolean ``` ``` operator fun OpenEndRange<Short>.contains(     value: Long ): Boolean ``` ``` operator fun OpenEndRange<Int>.contains(     value: Short ): Boolean ``` ``` operator fun OpenEndRange<Long>.contains(     value: Short ): Boolean ``` ``` operator fun OpenEndRange<Byte>.contains(     value: Short ): Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharRange](../-char-range/index) A range of values of type `Char`. ``` class CharRange :      CharProgression,     ClosedRange<Char>,     OpenEndRange<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntRange](../-int-range/index) A range of values of type `Int`. ``` class IntRange :      IntProgression,     ClosedRange<Int>,     OpenEndRange<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongRange](../-long-range/index) A range of values of type `Long`. ``` class LongRange :      LongProgression,     ClosedRange<Long>,     OpenEndRange<Long> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UIntRange](../-u-int-range/index) A range of values of type `UInt`. ``` class UIntRange :      UIntProgression,     ClosedRange<UInt>,     OpenEndRange<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongRange](../-u-long-range/index) A range of values of type `ULong`. ``` class ULongRange :      ULongProgression,     ClosedRange<ULong>,     OpenEndRange<ULong> ``` kotlin start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [OpenEndRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val start: T ``` The minimum value in the range. kotlin endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [OpenEndRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val endExclusive: T ``` The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](index#T). kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [OpenEndRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks whether the range is empty. The open-ended range is empty if its start value is greater than or equal to the end value. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(value: Char): Boolean ``` Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the [start](../-open-end-range/start) bound and strictly less than the [endExclusive](../-open-end-range/end-exclusive) bound. kotlin CharRange CharRange ========= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` class CharRange :      CharProgression,     ClosedRange<Char>,     OpenEndRange<Char> ``` A range of values of type `Char`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A range of values of type `Char`. ``` CharRange(start: Char, endInclusive: Char) ``` Properties ---------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` val endExclusive: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) ``` val endInclusive: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` val start: Char ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` fun contains(value: Char): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isEmpty](is-empty) Checks whether the range is empty. ``` 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. ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EMPTY](-e-m-p-t-y) An empty range of values of type Char. ``` val EMPTY: CharRange ``` 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) #### [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.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) #### [contains](../contains) Returns `true` if this range contains the specified [element](../contains#kotlin.ranges%24contains(kotlin.ranges.CharRange,%20kotlin.Char?)/element). ``` operator fun CharRange.contains(element: Char?): Boolean ``` **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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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 ``` **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 ``` **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? ``` **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.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 <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` **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.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 <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this range. ``` fun CharRange.random(): Char ``` Returns a random element from this range using the specified source of randomness. ``` fun CharRange.random(random: Random): Char ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun CharRange.randomOrNull(): Char? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun CharRange.randomOrNull(random: Random): Char? ``` **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) #### [requireNoNulls](../../kotlin.collections/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.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, 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](../../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 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](../../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) #### [sorted](../../kotlin.collections/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](../../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) #### [sortedDescending](../../kotlin.collections/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](../../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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun CharProgression.step(step: Int): CharProgression ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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 start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val start: Char ``` The minimum value in the range. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](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 EMPTY EMPTY ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / [EMPTY](-e-m-p-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val EMPTY: CharRange ``` An empty range of values of type Char. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](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 endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi val endExclusive: Char ``` **Deprecated:** Can throw an exception when it's impossible to represent the value with Char type, for example, when the range includes MAX\_VALUE. It's recommended to use 'endInclusive' property that doesn't throw. The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](../-open-end-range/index#T). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` CharRange(start: Char, endInclusive: Char) ``` A range of values of type `Char`. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](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. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` Checks whether the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [CharRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val endInclusive: Char ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(value: Long): Boolean ``` Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the [start](../-open-end-range/start) bound and strictly less than the [endExclusive](../-open-end-range/end-exclusive) bound. kotlin LongRange LongRange ========= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` class LongRange :      LongProgression,     ClosedRange<Long>,     OpenEndRange<Long> ``` A range of values of type `Long`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A range of values of type `Long`. ``` LongRange(start: Long, endInclusive: Long) ``` Properties ---------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` val endExclusive: Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) ``` val endInclusive: Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` val start: Long ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` fun contains(value: Long): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isEmpty](is-empty) Checks whether the range is empty. ``` 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. ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EMPTY](-e-m-p-t-y) An empty range of values of type Long. ``` val EMPTY: LongRange ``` 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) #### [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) #### [average](../../kotlin.collections/average) Returns an average value of elements in the collection. ``` fun Iterable<Long>.average(): Double ``` **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) #### [contains](../contains) Returns `true` if this range contains the specified [element](../contains#kotlin.ranges%24contains(kotlin.ranges.LongRange,%20kotlin.Long?)/element). ``` operator fun LongRange.contains(element: Long?): Boolean ``` Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.LongRange,%20kotlin.Byte)/value) belongs to this range. ``` operator fun LongRange.contains(value: Byte): Boolean ``` ``` operator fun LongRange.contains(value: Int): Boolean ``` ``` operator fun LongRange.contains(value: Short): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Float ): Boolean ``` **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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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 ``` **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 ``` **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? ``` **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.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 <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` **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.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 <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this range. ``` fun LongRange.random(): Long ``` Returns a random element from this range using the specified source of randomness. ``` fun LongRange.random(random: Random): Long ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun LongRange.randomOrNull(): Long? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun LongRange.randomOrNull(random: Random): Long? ``` **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) #### [requireNoNulls](../../kotlin.collections/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.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, 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](../../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 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](../../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) #### [sorted](../../kotlin.collections/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](../../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) #### [sortedDescending](../../kotlin.collections/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](../../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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun LongProgression.step(step: Long): LongProgression ``` **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) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<Long>.sum(): Long ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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 start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val start: Long ``` The minimum value in the range. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](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 EMPTY EMPTY ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / [EMPTY](-e-m-p-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val EMPTY: LongRange ``` An empty range of values of type Long. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](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 endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi val endExclusive: Long ``` **Deprecated:** Can throw an exception when it's impossible to represent the value with Long type, for example, when the range includes MAX\_VALUE. It's recommended to use 'endInclusive' property that doesn't throw. The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](../-open-end-range/index#T). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` LongRange(start: Long, endInclusive: Long) ``` A range of values of type `Long`. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](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. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` Checks whether the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val endInclusive: Long ``` kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(value: UInt): Boolean ``` Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the [start](../-open-end-range/start) bound and strictly less than the [endExclusive](../-open-end-range/end-exclusive) bound. kotlin UIntRange UIntRange ========= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` class UIntRange :      UIntProgression,     ClosedRange<UInt>,     OpenEndRange<UInt> ``` A range of values of type `UInt`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A range of values of type `UInt`. ``` UIntRange(start: UInt, endInclusive: UInt) ``` Properties ---------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` val endExclusive: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) ``` val endInclusive: UInt ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` val start: UInt ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` fun contains(value: UInt): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isEmpty](is-empty) Checks if the range is empty. ``` 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. ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EMPTY](-e-m-p-t-y) An empty range of values of type UInt. ``` val EMPTY: UIntRange ``` 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) #### [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.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.5), JS (1.5), Native (1.5) #### [contains](../contains) Returns `true` if this range contains the specified [element](../contains#kotlin.ranges%24contains(kotlin.ranges.UIntRange,%20kotlin.UInt?)/element). ``` operator fun UIntRange.contains(element: UInt?): Boolean ``` Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.UIntRange,%20kotlin.UByte)/value) belongs to this range. ``` operator fun UIntRange.contains(value: UByte): Boolean ``` ``` operator fun UIntRange.contains(value: ULong): Boolean ``` ``` operator fun UIntRange.contains(value: UShort): Boolean ``` **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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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 ``` **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 ``` **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? ``` **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.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 <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` **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.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 <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [random](../random) Returns a random element from this range. ``` fun UIntRange.random(): UInt ``` Returns a random element from this range using the specified source of randomness. ``` fun UIntRange.random(random: Random): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [randomOrNull](../random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun UIntRange.randomOrNull(): UInt? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun UIntRange.randomOrNull(random: Random): UInt? ``` **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) #### [requireNoNulls](../../kotlin.collections/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.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, 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](../../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 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](../../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) #### [sorted](../../kotlin.collections/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](../../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) #### [sortedDescending](../../kotlin.collections/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](../../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.5), JS (1.5), Native (1.5) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun UIntProgression.step(step: Int): UIntProgression ``` **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.5), JS (1.5), Native (1.5) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<UInt>.sum(): UInt ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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 start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val start: UInt ``` The minimum value in the range. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](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 EMPTY EMPTY ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / [EMPTY](-e-m-p-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val EMPTY: UIntRange ``` An empty range of values of type UInt. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](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 endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi val endExclusive: UInt ``` **Deprecated:** Can throw an exception when it's impossible to represent the value with UInt type, for example, when the range includes MAX\_VALUE. It's recommended to use 'endInclusive' property that doesn't throw. The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](../-open-end-range/index#T). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` UIntRange(start: UInt, endInclusive: UInt) ``` A range of values of type `UInt`. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](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. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` Checks if the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [UIntRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val endInclusive: UInt ``` kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val last: Int ``` The last element in the progression. kotlin IntProgression IntProgression ============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open class IntProgression : Iterable<Int> ``` A progression of values of type `Int`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> The first element in the progression. ``` val first: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> The last element in the progression. ``` val last: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> The step of the progression. ``` val step: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks if the progression is empty. ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` open fun iterator(): IntIterator ``` **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 ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fromClosedRange](from-closed-range) Creates IntProgression within the specified bounds of a closed range. ``` fun fromClosedRange(     rangeStart: Int,     rangeEnd: Int,     step: Int ): IntProgression ``` 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) #### [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) #### [average](../../kotlin.collections/average) Returns an average value of elements in the collection. ``` fun Iterable<Int>.average(): Double ``` **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) #### [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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [first](../first) Returns the first element. ``` fun IntProgression.first(): Int ``` **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.7), JS (1.7), Native (1.7) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun IntProgression.firstOrNull(): Int? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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.7), JS (1.7), Native (1.7) #### [last](../last) Returns the last element. ``` fun IntProgression.last(): Int ``` **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 ``` **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 ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun IntProgression.lastOrNull(): 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? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **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) #### [requireNoNulls](../../kotlin.collections/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 progression that goes over the same range in the opposite direction with the same step. ``` fun IntProgression.reversed(): IntProgression ``` **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, 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](../../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 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](../../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) #### [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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun IntProgression.step(step: Int): IntProgression ``` **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) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<Int>.sum(): Int ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntRange](../-int-range/index) A range of values of type `Int`. ``` class IntRange :      IntProgression,     ClosedRange<Int>,     OpenEndRange<Int> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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 iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun iterator(): IntIterator ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](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 fromClosedRange fromClosedRange =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / [fromClosedRange](from-closed-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun fromClosedRange(     rangeStart: Int,     rangeEnd: Int,     step: Int ): IntProgression ``` Creates IntProgression within the specified bounds of a closed range. The progression starts with the [rangeStart](from-closed-range#kotlin.ranges.IntProgression.Companion%24fromClosedRange(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/rangeStart) value and goes toward the [rangeEnd](from-closed-range#kotlin.ranges.IntProgression.Companion%24fromClosedRange(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/rangeEnd) value not excluding it, with the specified [step](from-closed-range#kotlin.ranges.IntProgression.Companion%24fromClosedRange(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/step). In order to go backwards the [step](from-closed-range#kotlin.ranges.IntProgression.Companion%24fromClosedRange(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/step) must be negative. [step](from-closed-range#kotlin.ranges.IntProgression.Companion%24fromClosedRange(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/step) must be greater than `Int.MIN_VALUE` and not equal to zero. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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. kotlin step step ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val step: Int ``` The step of the progression. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks if the progression is empty. Progression with a positive step is empty if its first element is greater than the last element. Progression with a negative step is empty if its first element is less than the last element. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntProgression](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: Int ``` The first element in the progression. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(value: Int): Boolean ``` Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. A value belongs to the open-ended range if it is greater than or equal to the [start](../-open-end-range/start) bound and strictly less than the [endExclusive](../-open-end-range/end-exclusive) bound. kotlin IntRange IntRange ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` class IntRange :      IntProgression,     ClosedRange<Int>,     OpenEndRange<Int> ``` A range of values of type `Int`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) A range of values of type `Int`. ``` IntRange(start: Int, endInclusive: Int) ``` Properties ---------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [endExclusive](end-exclusive) The maximum value in the range (exclusive). ``` val endExclusive: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) ``` val endInclusive: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` val start: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](../-open-end-range/contains#kotlin.ranges.OpenEndRange%24contains(kotlin.ranges.OpenEndRange.T)/value) belongs to the range. ``` fun contains(value: Int): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isEmpty](is-empty) Checks whether the range is empty. ``` 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. ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EMPTY](-e-m-p-t-y) An empty range of values of type Int. ``` val EMPTY: IntRange ``` 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) #### [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) #### [average](../../kotlin.collections/average) Returns an average value of elements in the collection. ``` fun Iterable<Int>.average(): Double ``` **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) #### [contains](../contains) Returns `true` if this range contains the specified [element](../contains#kotlin.ranges%24contains(kotlin.ranges.IntRange,%20kotlin.Int?)/element). ``` operator fun IntRange.contains(element: Int?): Boolean ``` Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.IntRange,%20kotlin.Byte)/value) belongs to this range. ``` operator fun IntRange.contains(value: Byte): Boolean ``` ``` operator fun IntRange.contains(value: Long): Boolean ``` ``` operator fun IntRange.contains(value: Short): Boolean ``` ``` operator fun ClosedRange<Int>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Float): Boolean ``` **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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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 ``` **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 ``` **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? ``` **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.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 <T : Comparable<T>> Iterable<T>.maxOrNull(): T? ``` **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.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 <T : Comparable<T>> Iterable<T>.minOrNull(): T? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../random) Returns a random element from this range. ``` fun IntRange.random(): Int ``` Returns a random element from this range using the specified source of randomness. ``` fun IntRange.random(random: Random): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [randomOrNull](../random-or-null) Returns a random element from this range, or `null` if this range is empty. ``` fun IntRange.randomOrNull(): Int? ``` Returns a random element from this range using the specified source of randomness, or `null` if this range is empty. ``` fun IntRange.randomOrNull(random: Random): Int? ``` **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) #### [requireNoNulls](../../kotlin.collections/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.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, 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](../../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 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](../../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) #### [sorted](../../kotlin.collections/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](../../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) #### [sortedDescending](../../kotlin.collections/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](../../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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun IntProgression.step(step: Int): IntProgression ``` **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) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<Int>.sum(): Int ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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 start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val start: Int ``` The minimum value in the range. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](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 EMPTY EMPTY ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / [EMPTY](-e-m-p-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val EMPTY: IntRange ``` An empty range of values of type Int. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](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 endExclusive endExclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / [endExclusive](end-exclusive) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi val endExclusive: Int ``` **Deprecated:** Can throw an exception when it's impossible to represent the value with Int type, for example, when the range includes MAX\_VALUE. It's recommended to use 'endInclusive' property that doesn't throw. The maximum value in the range (exclusive). Exceptions ---------- `IllegalStateException` - can be thrown if the exclusive end bound cannot be represented with a value of type [T](../-open-end-range/index#T). kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` IntRange(start: Int, endInclusive: Int) ``` A range of values of type `Int`. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](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. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isEmpty(): Boolean ``` Checks whether the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [IntRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val endInclusive: Int ``` kotlin last last ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / <last> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val last: Long ``` The last element in the progression. kotlin LongProgression LongProgression =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open class LongProgression : Iterable<Long> ``` A progression of values of type `Long`. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> The first element in the progression. ``` val first: Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <last> The last element in the progression. ``` val last: Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <step> The step of the progression. ``` val step: Long ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks if the progression is empty. ``` open fun isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> ``` open fun iterator(): LongIterator ``` **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 ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [fromClosedRange](from-closed-range) Creates LongProgression within the specified bounds of a closed range. ``` fun fromClosedRange(     rangeStart: Long,     rangeEnd: Long,     step: Long ): LongProgression ``` 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) #### [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) #### [average](../../kotlin.collections/average) Returns an average value of elements in the collection. ``` fun Iterable<Long>.average(): Double ``` **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) #### [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) #### [count](../../kotlin.collections/count) Returns the number of elements in this collection. ``` fun <T> Iterable<T>.count(): Int ``` 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) #### [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) #### [elementAt](../../kotlin.collections/element-at) Returns an element at the given [index](../../kotlin.collections/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](../../kotlin.collections/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](../../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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.collections.Iterable((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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](../../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) #### [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.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? ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [first](../first) Returns the first element. ``` fun LongProgression.first(): Long ``` **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.7), JS (1.7), Native (1.7) #### [firstOrNull](../first-or-null) Returns the first element, or `null` if the progression is empty. ``` fun LongProgression.firstOrNull(): Long? ``` **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) #### [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) #### [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) #### [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.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 ``` **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 ``` **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 ``` **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) #### [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.7), JS (1.7), Native (1.7) #### [last](../last) Returns the last element. ``` fun LongProgression.last(): Long ``` **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 ``` **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 ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [lastOrNull](../last-or-null) Returns the last element, or `null` if the progression is empty. ``` fun LongProgression.lastOrNull(): Long? ``` **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? ``` **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> ``` 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> ``` 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> ``` 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> ``` **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> ``` **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) #### [requireNoNulls](../../kotlin.collections/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 progression that goes over the same range in the opposite direction with the same step. ``` fun LongProgression.reversed(): LongProgression ``` **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, 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](../../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 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](../../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) #### [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) #### [step](../step) Returns a progression that goes over the same range with the given step. ``` infix fun LongProgression.step(step: Long): LongProgression ``` **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) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the collection. ``` fun Iterable<Long>.sum(): Long ``` **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) #### [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) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-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](../../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.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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongRange](../-long-range/index) A range of values of type `Long`. ``` class LongRange :      LongProgression,     ClosedRange<Long>,     OpenEndRange<Long> ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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 iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun iterator(): LongIterator ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](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 fromClosedRange fromClosedRange =============== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / [fromClosedRange](from-closed-range) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun fromClosedRange(     rangeStart: Long,     rangeEnd: Long,     step: Long ): LongProgression ``` Creates LongProgression within the specified bounds of a closed range. The progression starts with the [rangeStart](from-closed-range#kotlin.ranges.LongProgression.Companion%24fromClosedRange(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/rangeStart) value and goes toward the [rangeEnd](from-closed-range#kotlin.ranges.LongProgression.Companion%24fromClosedRange(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/rangeEnd) value not excluding it, with the specified [step](from-closed-range#kotlin.ranges.LongProgression.Companion%24fromClosedRange(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/step). In order to go backwards the [step](from-closed-range#kotlin.ranges.LongProgression.Companion%24fromClosedRange(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/step) must be negative. [step](from-closed-range#kotlin.ranges.LongProgression.Companion%24fromClosedRange(kotlin.Long,%20kotlin.Long,%20kotlin.Long)/step) must be greater than `Long.MIN_VALUE` and not equal to zero. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open 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. kotlin step step ==== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / <step> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val step: Long ``` The step of the progression. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks if the progression is empty. Progression with a positive step is empty if its first element is greater than the last element. Progression with a negative step is empty if its first element is less than the last element. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [LongProgression](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: Long ``` The first element in the progression. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedRange](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open operator fun contains(value: T): Boolean ``` Checks whether the specified [value](contains#kotlin.ranges.ClosedRange%24contains(kotlin.ranges.ClosedRange.T)/value) belongs to the range. A value belongs to the closed range if it is greater than or equal to the <start> bound and less than or equal to the [endInclusive](end-inclusive) bound. kotlin ClosedRange ClosedRange =========== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedRange](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` interface ClosedRange<T : Comparable<T>> ``` Represents a range of values (for example, numbers or characters) where both the lower and upper bounds are included in the range. See the [Kotlin language documentation](../../../../../../docs/ranges) for more information. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [endInclusive](end-inclusive) The maximum value in the range (inclusive). ``` abstract val endInclusive: T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <start> The minimum value in the range. ``` abstract val start: T ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contains> Checks whether the specified [value](contains#kotlin.ranges.ClosedRange%24contains(kotlin.ranges.ClosedRange.T)/value) belongs to the range. ``` open operator fun contains(value: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](is-empty) Checks whether the range is empty. ``` open fun isEmpty(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../contains) Checks if the specified [value](../contains#kotlin.ranges%24contains(kotlin.ranges.ClosedRange((kotlin.Int)),%20kotlin.Byte)/value) belongs to this range. ``` operator fun ClosedRange<Int>.contains(value: Byte): Boolean ``` ``` operator fun ClosedRange<Long>.contains(value: Byte): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Byte ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Byte ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Byte ): Boolean ``` ``` operator fun ClosedRange<Int>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Double ): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Float): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Float ): Boolean ``` ``` operator fun ClosedRange<Long>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Short>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Int ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(value: Int): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Long): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(value: Long): Boolean ``` ``` operator fun ClosedRange<Short>.contains(     value: Long ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Long ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Long ): Boolean ``` ``` operator fun ClosedRange<Int>.contains(value: Short): Boolean ``` ``` operator fun ClosedRange<Long>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Byte>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Double>.contains(     value: Short ): Boolean ``` ``` operator fun ClosedRange<Float>.contains(     value: Short ): Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharRange](../-char-range/index) A range of values of type `Char`. ``` class CharRange :      CharProgression,     ClosedRange<Char>,     OpenEndRange<Char> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ClosedFloatingPointRange](../-closed-floating-point-range/index) Represents a range of floating point numbers. Extends [ClosedRange](index) interface providing custom operation [lessThanOrEquals](../-closed-floating-point-range/less-than-or-equals) for comparing values of range domain type. ``` interface ClosedFloatingPointRange<T : Comparable<T>> :      ClosedRange<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntRange](../-int-range/index) A range of values of type `Int`. ``` class IntRange :      IntProgression,     ClosedRange<Int>,     OpenEndRange<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongRange](../-long-range/index) A range of values of type `Long`. ``` class LongRange :      LongProgression,     ClosedRange<Long>,     OpenEndRange<Long> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UIntRange](../-u-int-range/index) A range of values of type `UInt`. ``` class UIntRange :      UIntProgression,     ClosedRange<UInt>,     OpenEndRange<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULongRange](../-u-long-range/index) A range of values of type `ULong`. ``` class ULongRange :      ULongProgression,     ClosedRange<ULong>,     OpenEndRange<ULong> ``` kotlin start start ===== [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedRange](index) / <start> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val start: T ``` The minimum value in the range. kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedRange](index) / [isEmpty](is-empty) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` open fun isEmpty(): Boolean ``` Checks whether the range is empty. The range is empty if its start value is greater than the end value. kotlin endInclusive endInclusive ============ [kotlin-stdlib](../../../../../../index) / [kotlin.ranges](../index) / [ClosedRange](index) / [endInclusive](end-inclusive) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val endInclusive: T ``` The maximum value in the range (inclusive). kotlin Package kotlin.annotation Package kotlin.annotation ========================= [kotlin-stdlib](../../../../../index) / [kotlin.annotation](index) Library support for the Kotlin annotation facility. Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AnnotationRetention](-annotation-retention/index) Contains the list of possible annotation's retentions. ``` enum class AnnotationRetention ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AnnotationTarget](-annotation-target/index) Contains the list of code elements which are the possible annotation targets ``` enum class AnnotationTarget ``` Annotations ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MustBeDocumented](-must-be-documented/index) This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. ``` annotation class MustBeDocumented ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Repeatable](-repeatable/index) This meta-annotation determines that an annotation is applicable twice or more on a single code element ``` annotation class Repeatable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Retention](-retention/index) This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. ``` annotation class Retention ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Target](-target/index) This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. ``` annotation class Target ``` kotlin Repeatable Repeatable ========== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Repeatable](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class Repeatable ``` This meta-annotation determines that an annotation is applicable twice or more on a single code element Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This meta-annotation determines that an annotation is applicable twice or more on a single code element ``` <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.annotation](../index) / [Repeatable](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` <init>() ``` This meta-annotation determines that an annotation is applicable twice or more on a single code element kotlin Target Target ====== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Target](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class Target ``` This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. If the target meta-annotation is not present on an annotation declaration, the annotation is applicable to the following elements: [CLASS](../-annotation-target/-c-l-a-s-s#kotlin.annotation.AnnotationTarget.CLASS), [PROPERTY](../-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY), [FIELD](../-annotation-target/-f-i-e-l-d#kotlin.annotation.AnnotationTarget.FIELD), [LOCAL\_VARIABLE](../-annotation-target/-l-o-c-a-l_-v-a-r-i-a-b-l-e#kotlin.annotation.AnnotationTarget.LOCAL_VARIABLE), [VALUE\_PARAMETER](../-annotation-target/-v-a-l-u-e_-p-a-r-a-m-e-t-e-r#kotlin.annotation.AnnotationTarget.VALUE_PARAMETER), [CONSTRUCTOR](../-annotation-target/-c-o-n-s-t-r-u-c-t-o-r#kotlin.annotation.AnnotationTarget.CONSTRUCTOR), [FUNCTION](../-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION), [PROPERTY\_GETTER](../-annotation-target/-p-r-o-p-e-r-t-y_-g-e-t-t-e-r#kotlin.annotation.AnnotationTarget.PROPERTY_GETTER), [PROPERTY\_SETTER](../-annotation-target/-p-r-o-p-e-r-t-y_-s-e-t-t-e-r#kotlin.annotation.AnnotationTarget.PROPERTY_SETTER). Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. ``` <init>(vararg allowedTargets: AnnotationTarget) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [allowedTargets](allowed-targets) list of allowed annotation targets ``` vararg val allowedTargets: Array<out AnnotationTarget> ``` 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 allowedTargets allowedTargets ============== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Target](index) / [allowedTargets](allowed-targets) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` vararg val allowedTargets: Array<out AnnotationTarget> ``` list of allowed annotation targets Property -------- `allowedTargets` - list of allowed annotation targets kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Target](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` <init>(vararg allowedTargets: AnnotationTarget) ``` This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. If the target meta-annotation is not present on an annotation declaration, the annotation is applicable to the following elements: [CLASS](../-annotation-target/-c-l-a-s-s#kotlin.annotation.AnnotationTarget.CLASS), [PROPERTY](../-annotation-target/-p-r-o-p-e-r-t-y#kotlin.annotation.AnnotationTarget.PROPERTY), [FIELD](../-annotation-target/-f-i-e-l-d#kotlin.annotation.AnnotationTarget.FIELD), [LOCAL\_VARIABLE](../-annotation-target/-l-o-c-a-l_-v-a-r-i-a-b-l-e#kotlin.annotation.AnnotationTarget.LOCAL_VARIABLE), [VALUE\_PARAMETER](../-annotation-target/-v-a-l-u-e_-p-a-r-a-m-e-t-e-r#kotlin.annotation.AnnotationTarget.VALUE_PARAMETER), [CONSTRUCTOR](../-annotation-target/-c-o-n-s-t-r-u-c-t-o-r#kotlin.annotation.AnnotationTarget.CONSTRUCTOR), [FUNCTION](../-annotation-target/-f-u-n-c-t-i-o-n#kotlin.annotation.AnnotationTarget.FUNCTION), [PROPERTY\_GETTER](../-annotation-target/-p-r-o-p-e-r-t-y_-g-e-t-t-e-r#kotlin.annotation.AnnotationTarget.PROPERTY_GETTER), [PROPERTY\_SETTER](../-annotation-target/-p-r-o-p-e-r-t-y_-s-e-t-t-e-r#kotlin.annotation.AnnotationTarget.PROPERTY_SETTER). kotlin BINARY BINARY ====== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationRetention](index) / [BINARY](-b-i-n-a-r-y) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` BINARY ``` Annotation is stored in binary output, but invisible for reflection
programming_docs
kotlin AnnotationRetention AnnotationRetention =================== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationRetention](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` enum class AnnotationRetention ``` Contains the list of possible annotation's retentions. Determines how an annotation is stored in binary output. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SOURCE](-s-o-u-r-c-e) Annotation isn't stored in binary output **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BINARY](-b-i-n-a-r-y) Annotation is stored in binary output, but invisible for reflection **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [RUNTIME](-r-u-n-t-i-m-e) Annotation is stored in binary output and visible for reflection (default retention) Extension Properties -------------------- **Platform and version requirements:** JVM (1.7) #### [declaringJavaClass](../../kotlin.jvm/declaring-java-class) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance of the enum the given constant belongs to. ``` val <E : Enum<E>> Enum<E>.declaringJavaClass: Class<E> ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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](../../kotlin/compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../../kotlin/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:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../../kotlin/-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](../../kotlin/-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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BINARY](-b-i-n-a-r-y) Annotation is stored in binary output, but invisible for reflection **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [RUNTIME](-r-u-n-t-i-m-e) Annotation is stored in binary output and visible for reflection (default retention) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SOURCE](-s-o-u-r-c-e) Annotation isn't stored in binary output kotlin SOURCE SOURCE ====== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationRetention](index) / [SOURCE](-s-o-u-r-c-e) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` SOURCE ``` Annotation isn't stored in binary output kotlin RUNTIME RUNTIME ======= [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationRetention](index) / [RUNTIME](-r-u-n-t-i-m-e) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` RUNTIME ``` Annotation is stored in binary output and visible for reflection (default retention) kotlin Retention Retention ========= [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Retention](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class Retention ``` This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. ``` <init>(     value: AnnotationRetention = AnnotationRetention.RUNTIME) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <value> necessary annotation retention (RUNTIME, BINARY or SOURCE) ``` val value: AnnotationRetention ``` 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.annotation](../index) / [Retention](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` <init>(     value: AnnotationRetention = AnnotationRetention.RUNTIME) ``` This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. kotlin value value ===== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [Retention](index) / <value> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` val value: AnnotationRetention ``` necessary annotation retention (RUNTIME, BINARY or SOURCE) Property -------- `value` - necessary annotation retention (RUNTIME, BINARY or SOURCE) kotlin TYPE_PARAMETER TYPE\_PARAMETER =============== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [TYPE\_PARAMETER](-t-y-p-e_-p-a-r-a-m-e-t-e-r) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` TYPE_PARAMETER ``` ##### For Common, JVM, JS Generic type parameter ##### For Native Generic type parameter (unsupported yet) kotlin FILE FILE ==== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [FILE](-f-i-l-e) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` FILE ``` File kotlin CONSTRUCTOR CONSTRUCTOR =========== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [CONSTRUCTOR](-c-o-n-s-t-r-u-c-t-o-r) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` CONSTRUCTOR ``` Constructor only (primary or secondary) kotlin TYPEALIAS TYPEALIAS ========= [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [TYPEALIAS](-t-y-p-e-a-l-i-a-s) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` TYPEALIAS ``` Type alias kotlin AnnotationTarget AnnotationTarget ================ [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` enum class AnnotationTarget ``` Contains the list of code elements which are the possible annotation targets Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CLASS](-c-l-a-s-s) Class, interface or object, annotation class is also included **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ANNOTATION\_CLASS](-a-n-n-o-t-a-t-i-o-n_-c-l-a-s-s) Annotation class only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [TYPE\_PARAMETER](-t-y-p-e_-p-a-r-a-m-e-t-e-r) Generic type parameter **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY](-p-r-o-p-e-r-t-y) Property **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FIELD](-f-i-e-l-d) Field, including property's backing field **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LOCAL\_VARIABLE](-l-o-c-a-l_-v-a-r-i-a-b-l-e) Local variable **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [VALUE\_PARAMETER](-v-a-l-u-e_-p-a-r-a-m-e-t-e-r) Value parameter of a function or a constructor **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CONSTRUCTOR](-c-o-n-s-t-r-u-c-t-o-r) Constructor only (primary or secondary) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FUNCTION](-f-u-n-c-t-i-o-n) Function (constructors are not included) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY\_GETTER](-p-r-o-p-e-r-t-y_-g-e-t-t-e-r) Property getter only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY\_SETTER](-p-r-o-p-e-r-t-y_-s-e-t-t-e-r) Property setter only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [TYPE](-t-y-p-e) Type usage **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EXPRESSION](-e-x-p-r-e-s-s-i-o-n) Any expression **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FILE](-f-i-l-e) File **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [TYPEALIAS](-t-y-p-e-a-l-i-a-s) Type alias Extension Properties -------------------- **Platform and version requirements:** JVM (1.7) #### [declaringJavaClass](../../kotlin.jvm/declaring-java-class) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance of the enum the given constant belongs to. ``` val <E : Enum<E>> Enum<E>.declaringJavaClass: Class<E> ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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](../../kotlin/compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../../kotlin/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:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../../kotlin/-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](../../kotlin/-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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ANNOTATION\_CLASS](-a-n-n-o-t-a-t-i-o-n_-c-l-a-s-s) Annotation class only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CLASS](-c-l-a-s-s) Class, interface or object, annotation class is also included **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CONSTRUCTOR](-c-o-n-s-t-r-u-c-t-o-r) Constructor only (primary or secondary) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EXPRESSION](-e-x-p-r-e-s-s-i-o-n) Any expression **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FIELD](-f-i-e-l-d) Field, including property's backing field **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FILE](-f-i-l-e) File **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FUNCTION](-f-u-n-c-t-i-o-n) Function (constructors are not included) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LOCAL\_VARIABLE](-l-o-c-a-l_-v-a-r-i-a-b-l-e) Local variable **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY](-p-r-o-p-e-r-t-y) Property **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY\_GETTER](-p-r-o-p-e-r-t-y_-g-e-t-t-e-r) Property getter only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PROPERTY\_SETTER](-p-r-o-p-e-r-t-y_-s-e-t-t-e-r) Property setter only **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [TYPE](-t-y-p-e) Type usage **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [TYPE\_PARAMETER](-t-y-p-e_-p-a-r-a-m-e-t-e-r) Generic type parameter **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [TYPEALIAS](-t-y-p-e-a-l-i-a-s) Type alias **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [VALUE\_PARAMETER](-v-a-l-u-e_-p-a-r-a-m-e-t-e-r) Value parameter of a function or a constructor kotlin TYPE TYPE ==== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [TYPE](-t-y-p-e) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` TYPE ``` Type usage kotlin VALUE_PARAMETER VALUE\_PARAMETER ================ [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [VALUE\_PARAMETER](-v-a-l-u-e_-p-a-r-a-m-e-t-e-r) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` VALUE_PARAMETER ``` Value parameter of a function or a constructor kotlin LOCAL_VARIABLE LOCAL\_VARIABLE =============== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [LOCAL\_VARIABLE](-l-o-c-a-l_-v-a-r-i-a-b-l-e) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` LOCAL_VARIABLE ``` Local variable kotlin FUNCTION FUNCTION ======== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [FUNCTION](-f-u-n-c-t-i-o-n) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` FUNCTION ``` Function (constructors are not included) kotlin CLASS CLASS ===== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [CLASS](-c-l-a-s-s) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` CLASS ``` Class, interface or object, annotation class is also included kotlin FIELD FIELD ===== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [FIELD](-f-i-e-l-d) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` FIELD ``` Field, including property's backing field
programming_docs
kotlin PROPERTY_GETTER PROPERTY\_GETTER ================ [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [PROPERTY\_GETTER](-p-r-o-p-e-r-t-y_-g-e-t-t-e-r) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` PROPERTY_GETTER ``` Property getter only kotlin EXPRESSION EXPRESSION ========== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [EXPRESSION](-e-x-p-r-e-s-s-i-o-n) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` EXPRESSION ``` Any expression kotlin PROPERTY_SETTER PROPERTY\_SETTER ================ [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [PROPERTY\_SETTER](-p-r-o-p-e-r-t-y_-s-e-t-t-e-r) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` PROPERTY_SETTER ``` Property setter only kotlin PROPERTY PROPERTY ======== [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [PROPERTY](-p-r-o-p-e-r-t-y) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` PROPERTY ``` Property kotlin ANNOTATION_CLASS ANNOTATION\_CLASS ================= [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [AnnotationTarget](index) / [ANNOTATION\_CLASS](-a-n-n-o-t-a-t-i-o-n_-c-l-a-s-s) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` ANNOTATION_CLASS ``` Annotation class only kotlin MustBeDocumented MustBeDocumented ================ [kotlin-stdlib](../../../../../../index) / [kotlin.annotation](../index) / [MustBeDocumented](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class MustBeDocumented ``` This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. ``` <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.annotation](../index) / [MustBeDocumented](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` <init>() ``` This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. kotlin isText isText ====== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [isText](is-text) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val Node.isText: Boolean ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.isText' instead. Gets a value indicating whether this node is a TEXT\_NODE or a CDATA\_SECTION\_NODE. kotlin Package kotlin.dom Package kotlin.dom ================== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) Utility functions for working with the browser DOM. Properties ---------- **Platform and version requirements:** JS (1.1) #### [isElement](is-element) Gets a value indicating whether this node is an [Element](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-element/index.html). ``` val Node.isElement: Boolean ``` **Platform and version requirements:** JS (1.1) #### [isText](is-text) Gets a value indicating whether this node is a TEXT\_NODE or a CDATA\_SECTION\_NODE. ``` val Node.isText: Boolean ``` Functions --------- **Platform and version requirements:** JS (1.1) #### [addClass](add-class) Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element ``` fun Element.addClass(vararg cssClasses: String): Boolean ``` **Platform and version requirements:** JS (1.1) #### [appendElement](append-element) Appends a newly created element with the specified [name](append-element#kotlin.dom%24appendElement(org.w3c.dom.Element,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/name) to this element. ``` fun Element.appendElement(     name: String,     init: Element.() -> Unit ): Element ``` **Platform and version requirements:** JS (1.1) #### [appendText](append-text) Creates text node and append it to the element. ``` fun Element.appendText(text: String): Element ``` **Platform and version requirements:** JS (1.1) #### <clear> Removes all the children from this node. ``` fun Node.clear() ``` **Platform and version requirements:** JS (1.1) #### [createElement](create-element) Creates a new element with the specified [name](create-element#kotlin.dom%24createElement(org.w3c.dom.Document,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/name). ``` fun Document.createElement(     name: String,     init: Element.() -> Unit ): Element ``` **Platform and version requirements:** JS (1.1) #### [hasClass](has-class) Returns true if the element has the given CSS class style in its 'class' attribute ``` fun Element.hasClass(cssClass: String): Boolean ``` **Platform and version requirements:** JS (1.1) #### [removeClass](remove-class) Removes all [cssClasses](remove-class#kotlin.dom%24removeClass(org.w3c.dom.Element,%20kotlin.Array((kotlin.String)))/cssClasses) from element. Has no effect if all specified classes are missing in class attribute of the element ``` fun Element.removeClass(vararg cssClasses: String): Boolean ``` kotlin appendText appendText ========== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [appendText](append-text) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun Element.appendText(     text: String ): Element ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.appendText' instead. Creates text node and append it to the element. **Return** this element kotlin removeClass removeClass =========== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [removeClass](remove-class) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun Element.removeClass(     vararg cssClasses: String ): Boolean ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.removeClass' instead. Removes all [cssClasses](remove-class#kotlin.dom%24removeClass(org.w3c.dom.Element,%20kotlin.Array((kotlin.String)))/cssClasses) from element. Has no effect if all specified classes are missing in class attribute of the element **Return** true if at least one class has been removed kotlin hasClass hasClass ======== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [hasClass](has-class) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun Element.hasClass(     cssClass: String ): Boolean ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.hasClass' instead. Returns true if the element has the given CSS class style in its 'class' attribute kotlin clear clear ===== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / <clear> **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun Node.clear() ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.clear' instead. Removes all the children from this node. kotlin addClass addClass ======== [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [addClass](add-class) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") fun Element.addClass(     vararg cssClasses: String ): Boolean ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.addClass' instead. Adds CSS class to element. Has no effect if all specified classes are already in class attribute of the element **Return** true if at least one class has been added kotlin isElement isElement ========= [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [isElement](is-element) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") val Node.isElement: Boolean ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.isElement' instead. Gets a value indicating whether this node is an [Element](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-element/index.html). kotlin createElement createElement ============= [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [createElement](create-element) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") inline fun Document.createElement(     name: String,     noinline init: Element.() -> Unit ): Element ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.createElement' instead. Creates a new element with the specified [name](create-element#kotlin.dom%24createElement(org.w3c.dom.Document,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/name). The element is initialized with the specified [init](create-element#kotlin.dom%24createElement(org.w3c.dom.Document,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/init) function. kotlin appendElement appendElement ============= [kotlin-stdlib](../../../../../index) / [kotlin.dom](index) / [appendElement](append-element) **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.4", "1.6") inline fun Element.appendElement(     name: String,     noinline init: Element.() -> Unit ): Element ``` **Deprecated:** This API is moved to another package, use 'kotlinx.dom.appendElement' instead. Appends a newly created element with the specified [name](append-element#kotlin.dom%24appendElement(org.w3c.dom.Element,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/name) to this element. The element is initialized with the specified [init](append-element#kotlin.dom%24appendElement(org.w3c.dom.Element,%20kotlin.String,%20kotlin.Function1((org.w3c.dom.Element,%20kotlin.Unit)))/init) function. kotlin contract contract ======== [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / <contract> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts inline fun contract(     builder: ContractBuilder.() -> Unit) ``` Specifies the contract of a function. The contract description must be at the beginning of a function and have at least one effect. Only the top-level functions can have a contract for now. Parameters ---------- `builder` - the lambda where the contract of a function is described with the help of the [ContractBuilder](-contract-builder/index) members. kotlin Package kotlin.contracts Package kotlin.contracts ======================== [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) Experimental DSL for declaring custom function contracts. Types ----- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [CallsInPlace](-calls-in-place) An effect of calling a functional parameter in place. ``` interface CallsInPlace : Effect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ConditionalEffect](-conditional-effect) An effect of some condition being true after observing another effect of a function. ``` interface ConditionalEffect : Effect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ContractBuilder](-contract-builder/index) Provides a scope, where the functions of the contract DSL, such as [returns](-contract-builder/returns), [callsInPlace](-contract-builder/calls-in-place), etc., can be used to describe the contract of a function. ``` interface ContractBuilder ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Effect](-effect) Represents an effect of a function invocation, either directly observable, such as the function returning normally, or a side-effect, such as the function's lambda parameter being called in place. ``` interface Effect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [InvocationKind](-invocation-kind/index) Specifies how many times a function invokes its function parameter in place. ``` enum class InvocationKind ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Returns](-returns) Describes a situation when a function returns normally with a given return value. ``` interface Returns : SimpleEffect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ReturnsNotNull](-returns-not-null) Describes a situation when a function returns normally with any non-null return value. ``` interface ReturnsNotNull : SimpleEffect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SimpleEffect](-simple-effect/index) An effect that can be observed after a function invocation. ``` interface SimpleEffect : Effect ``` Annotations ----------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalContracts](-experimental-contracts/index) This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. ``` annotation class ExperimentalContracts ``` Functions --------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <contract> Specifies the contract of a function. ``` fun contract(builder: ContractBuilder.() -> Unit) ``` kotlin Returns Returns ======= [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / [Returns](-returns) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface Returns : SimpleEffect ``` Describes a situation when a function returns normally with a given return value. **See Also** [ContractBuilder.returns](-contract-builder/returns) kotlin ReturnsNotNull ReturnsNotNull ============== [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / [ReturnsNotNull](-returns-not-null) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface ReturnsNotNull :      SimpleEffect ``` Describes a situation when a function returns normally with any non-null return value. **See Also** [ContractBuilder.returnsNotNull](-contract-builder/returns-not-null) kotlin CallsInPlace CallsInPlace ============ [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / [CallsInPlace](-calls-in-place) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface CallsInPlace : Effect ``` An effect of calling a functional parameter in place. A function is said to call its functional parameter in place, if the functional parameter is only invoked while the execution has not been returned from the function, and the functional parameter cannot be invoked after the function is completed. **See Also** [ContractBuilder.callsInPlace](-contract-builder/calls-in-place) kotlin Effect Effect ====== [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / [Effect](-effect) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface Effect ``` Represents an effect of a function invocation, either directly observable, such as the function returning normally, or a side-effect, such as the function's lambda parameter being called in place. The inheritors are used in [ContractBuilder](-contract-builder/index) to describe the contract of a function. **See Also** [ConditionalEffect](-conditional-effect) [SimpleEffect](-simple-effect/index) [CallsInPlace](-calls-in-place) Inheritors ---------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [CallsInPlace](-calls-in-place) An effect of calling a functional parameter in place. ``` interface CallsInPlace : Effect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ConditionalEffect](-conditional-effect) An effect of some condition being true after observing another effect of a function. ``` interface ConditionalEffect : Effect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SimpleEffect](-simple-effect/index) An effect that can be observed after a function invocation. ``` interface SimpleEffect : Effect ``` kotlin ConditionalEffect ConditionalEffect ================= [kotlin-stdlib](../../../../../index) / [kotlin.contracts](index) / [ConditionalEffect](-conditional-effect) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface ConditionalEffect : Effect ``` An effect of some condition being true after observing another effect of a function. This effect is specified in the `contract { }` block by attaching a boolean expression to another [SimpleEffect](-simple-effect/index) effect with the function [SimpleEffect.implies](-simple-effect/implies). kotlin InvocationKind InvocationKind ============== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [InvocationKind](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts enum class InvocationKind ``` Specifies how many times a function invokes its function parameter in place. See [ContractBuilder.callsInPlace](../-contract-builder/calls-in-place) for the details of the call-in-place function contract. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AT\_MOST\_ONCE](-a-t_-m-o-s-t_-o-n-c-e) A function parameter will be invoked one time or not invoked at all. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AT\_LEAST\_ONCE](-a-t_-l-e-a-s-t_-o-n-c-e) A function parameter will be invoked one or more times. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [EXACTLY\_ONCE](-e-x-a-c-t-l-y_-o-n-c-e) A function parameter will be invoked exactly one time. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [UNKNOWN](-u-n-k-n-o-w-n) A function parameter is called in place, but it's unknown how many times it can be called. 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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](../../kotlin/compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../../kotlin/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:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../../kotlin/-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](../../kotlin/-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> ```
programming_docs
kotlin EXACTLY_ONCE EXACTLY\_ONCE ============= [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [InvocationKind](index) / [EXACTLY\_ONCE](-e-x-a-c-t-l-y_-o-n-c-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` EXACTLY_ONCE ``` A function parameter will be invoked exactly one time. kotlin AT_MOST_ONCE AT\_MOST\_ONCE ============== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [InvocationKind](index) / [AT\_MOST\_ONCE](-a-t_-m-o-s-t_-o-n-c-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` AT_MOST_ONCE ``` A function parameter will be invoked one time or not invoked at all. kotlin AT_LEAST_ONCE AT\_LEAST\_ONCE =============== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [InvocationKind](index) / [AT\_LEAST\_ONCE](-a-t_-l-e-a-s-t_-o-n-c-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` AT_LEAST_ONCE ``` A function parameter will be invoked one or more times. kotlin UNKNOWN UNKNOWN ======= [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [InvocationKind](index) / [UNKNOWN](-u-n-k-n-o-w-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` UNKNOWN ``` A function parameter is called in place, but it's unknown how many times it can be called. kotlin ExperimentalContracts ExperimentalContracts ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ExperimentalContracts](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` annotation class ExperimentalContracts ``` This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. Any usage of a declaration annotated with `@ExperimentalContracts` must be accepted either by annotating that usage with the [OptIn](../../kotlin/-opt-in/index) annotation, e.g. `@OptIn(ExperimentalContracts::class)`, or by using the compiler argument `-opt-in=kotlin.contracts.ExperimentalContracts`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. ``` ExperimentalContracts() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ExperimentalContracts](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ExperimentalContracts() ``` This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. Any usage of a declaration annotated with `@ExperimentalContracts` must be accepted either by annotating that usage with the [OptIn](../../kotlin/-opt-in/index) annotation, e.g. `@OptIn(ExperimentalContracts::class)`, or by using the compiler argument `-opt-in=kotlin.contracts.ExperimentalContracts`. kotlin implies implies ======= [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [SimpleEffect](index) / <implies> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @ExperimentalContracts abstract infix fun implies(     booleanExpression: Boolean ): ConditionalEffect ``` Specifies that this effect, when observed, guarantees [booleanExpression](implies#kotlin.contracts.SimpleEffect%24implies(kotlin.Boolean)/booleanExpression) to be true. Note: [booleanExpression](implies#kotlin.contracts.SimpleEffect%24implies(kotlin.Boolean)/booleanExpression) can accept only a subset of boolean expressions, where a function parameter or receiver (`this`) undergoes * true of false checks, in case if the parameter or receiver is `Boolean`; * null-checks (`== null`, `!= null`); * instance-checks (`is`, `!is`); * a combination of the above with the help of logic operators (`&&`, `||`, `!`). kotlin SimpleEffect SimpleEffect ============ [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [SimpleEffect](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface SimpleEffect : Effect ``` An effect that can be observed after a function invocation. **See Also** [ContractBuilder.returns](../-contract-builder/returns) [ContractBuilder.returnsNotNull](../-contract-builder/returns-not-null) Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <implies> Specifies that this effect, when observed, guarantees [booleanExpression](implies#kotlin.contracts.SimpleEffect%24implies(kotlin.Boolean)/booleanExpression) to be true. ``` abstract infix fun implies(     booleanExpression: Boolean ): ConditionalEffect ``` Inheritors ---------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Returns](../-returns) Describes a situation when a function returns normally with a given return value. ``` interface Returns : SimpleEffect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ReturnsNotNull](../-returns-not-null) Describes a situation when a function returns normally with any non-null return value. ``` interface ReturnsNotNull : SimpleEffect ``` kotlin returnsNotNull returnsNotNull ============== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ContractBuilder](index) / [returnsNotNull](returns-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun returnsNotNull(): ReturnsNotNull ``` Describes a situation when a function returns normally with any value that is not `null`. Use [SimpleEffect.implies](../-simple-effect/implies) function to describe a conditional effect that happens in such case. kotlin ContractBuilder ContractBuilder =============== [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ContractBuilder](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalContracts interface ContractBuilder ``` Provides a scope, where the functions of the contract DSL, such as <returns>, [callsInPlace](calls-in-place), etc., can be used to describe the contract of a function. This type is used as a receiver type of the lambda function passed to the [contract](../contract) function. **See Also** [contract](../contract) Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [callsInPlace](calls-in-place) Specifies that the function parameter [lambda](calls-in-place#kotlin.contracts.ContractBuilder%24callsInPlace(kotlin.Function((kotlin.contracts.ContractBuilder.callsInPlace.R)),%20kotlin.contracts.InvocationKind)/lambda) is invoked in place. ``` abstract fun <R> callsInPlace(     lambda: Function<R>,     kind: InvocationKind = InvocationKind.UNKNOWN ): CallsInPlace ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <returns> Describes a situation when a function returns normally, without any exceptions thrown. ``` abstract fun returns(): Returns ``` Describes a situation when a function returns normally with the specified return [value](returns#kotlin.contracts.ContractBuilder%24returns(kotlin.Any?)/value). ``` abstract fun returns(value: Any?): Returns ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [returnsNotNull](returns-not-null) Describes a situation when a function returns normally with any value that is not `null`. ``` abstract fun returnsNotNull(): ReturnsNotNull ``` kotlin callsInPlace callsInPlace ============ [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ContractBuilder](index) / [callsInPlace](calls-in-place) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun <R> callsInPlace(     lambda: Function<R>,     kind: InvocationKind = InvocationKind.UNKNOWN ): CallsInPlace ``` Specifies that the function parameter [lambda](calls-in-place#kotlin.contracts.ContractBuilder%24callsInPlace(kotlin.Function((kotlin.contracts.ContractBuilder.callsInPlace.R)),%20kotlin.contracts.InvocationKind)/lambda) is invoked in place. This contract specifies that: 1. the function [lambda](calls-in-place#kotlin.contracts.ContractBuilder%24callsInPlace(kotlin.Function((kotlin.contracts.ContractBuilder.callsInPlace.R)),%20kotlin.contracts.InvocationKind)/lambda) can only be invoked during the call of the owner function, and it won't be invoked after that owner function call is completed; 2. *(optionally)* the function [lambda](calls-in-place#kotlin.contracts.ContractBuilder%24callsInPlace(kotlin.Function((kotlin.contracts.ContractBuilder.callsInPlace.R)),%20kotlin.contracts.InvocationKind)/lambda) is invoked the amount of times specified by the [kind](calls-in-place#kotlin.contracts.ContractBuilder%24callsInPlace(kotlin.Function((kotlin.contracts.ContractBuilder.callsInPlace.R)),%20kotlin.contracts.InvocationKind)/kind) parameter, see the [InvocationKind](../-invocation-kind/index) enum for possible values. A function declaring the `callsInPlace` effect must be *inline*. kotlin returns returns ======= [kotlin-stdlib](../../../../../../index) / [kotlin.contracts](../index) / [ContractBuilder](index) / <returns> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun returns(): Returns ``` Describes a situation when a function returns normally, without any exceptions thrown. Use [SimpleEffect.implies](../-simple-effect/implies) function to describe a conditional effect that happens in such case. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun returns(value: Any?): Returns ``` Describes a situation when a function returns normally with the specified return [value](returns#kotlin.contracts.ContractBuilder%24returns(kotlin.Any?)/value). The possible values of [value](returns#kotlin.contracts.ContractBuilder%24returns(kotlin.Any?)/value) are limited to `true`, `false` or `null`. Use [SimpleEffect.implies](../-simple-effect/implies) function to describe a conditional effect that happens in such case. kotlin stringLengthBytes stringLengthBytes ================= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [stringLengthBytes](string-length-bytes) **Platform and version requirements:** Native (1.3) ``` fun stringLengthBytes(message: String): Int ``` kotlin Konan_js_getProperty Konan\_js\_getProperty ====================== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [Konan\_js\_getProperty](-konan_js_get-property) **Platform and version requirements:** Native (1.3) ``` fun Konan_js_getProperty(     arena: Arena,     obj: Object,     propertyPtr: Pointer,     propertyLen: Int ): Int ``` kotlin Package kotlinx.wasm.jsinterop Package kotlinx.wasm.jsinterop ============================== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) Types ----- **Platform and version requirements:** Native (1.3) #### [Arena](-arena) ``` typealias Arena = Int ``` **Platform and version requirements:** Native (1.3) #### [ArenaManager](-arena-manager/index) ``` object ArenaManager ``` **Platform and version requirements:** Native (1.3) #### [JsArray](-js-array/index) ``` open class JsArray : JsValue ``` **Platform and version requirements:** Native (1.3) #### [JsValue](-js-value/index) ``` open class JsValue ``` **Platform and version requirements:** Native (1.3) #### [KtFunction](-kt-function) ``` typealias KtFunction<R> = (ArrayList<JsValue>) -> R ``` **Platform and version requirements:** Native (1.3) #### [Object](-object) ``` typealias Object = Int ``` **Platform and version requirements:** Native (1.3) #### [Pointer](-pointer) ``` typealias Pointer = Int ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### [upperWord](upper-word) ``` const val upperWord: Long ``` Functions --------- **Platform and version requirements:** Native (1.3) #### [allocateArena](allocate-arena) ``` fun allocateArena(): Arena ``` **Platform and version requirements:** Native (1.3) #### [doubleLower](double-lower) ``` fun doubleLower(value: Double): Int ``` **Platform and version requirements:** Native (1.3) #### [doubleUpper](double-upper) ``` fun doubleUpper(value: Double): Int ``` **Platform and version requirements:** Native (1.3) #### [freeArena](free-arena) ``` fun freeArena(arena: Arena) ``` **Platform and version requirements:** Native (1.3) #### [getInt](get-int) ``` fun getInt(     arena: Arena,     obj: Object,     propertyPtr: Pointer,     propertyLen: Int ): Int ``` **Platform and version requirements:** Native (1.3) #### [Konan\_js\_getProperty](-konan_js_get-property) ``` fun Konan_js_getProperty(     arena: Arena,     obj: Object,     propertyPtr: Pointer,     propertyLen: Int ): Int ``` **Platform and version requirements:** Native (1.3) #### [pushIntToArena](push-int-to-arena) ``` fun pushIntToArena(arena: Arena, value: Int) ``` **Platform and version requirements:** Native (1.3) #### [ReturnSlot\_getDouble](-return-slot_get-double) ``` fun ReturnSlot_getDouble(): Double ``` **Platform and version requirements:** Native (1.3) #### [runLambda](run-lambda) ``` fun runLambda(     pointer: Int,     argumentsArena: Arena,     argumentsArenaSize: Int ): Int ``` **Platform and version requirements:** Native (1.3) #### [setFunction](set-function) ``` fun setFunction(     arena: Arena,     obj: Object,     propertyName: Pointer,     propertyLength: Int,     function: Int) ``` **Platform and version requirements:** Native (1.3) #### [setString](set-string) ``` fun setString(     arena: Arena,     obj: Object,     propertyName: Pointer,     propertyLength: Int,     stringPtr: Pointer,     stringLength: Int) ``` **Platform and version requirements:** Native (1.3) #### <setter> ``` fun setter(obj: JsValue, property: String, string: String) ``` ``` fun setter(     obj: JsValue,     property: String,     lambda: KtFunction<Unit>) ``` **Platform and version requirements:** Native (1.3) #### [stringLengthBytes](string-length-bytes) ``` fun stringLengthBytes(message: String): Int ``` **Platform and version requirements:** Native (1.3) #### [stringPointer](string-pointer) ``` fun stringPointer(message: String): Pointer ``` **Platform and version requirements:** Native (1.3) #### [wrapFunction](wrap-function) ``` fun <R> wrapFunction(func: KtFunction<R>): Int ``` kotlin KtFunction KtFunction ========== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [KtFunction](-kt-function) **Platform and version requirements:** Native (1.3) ``` typealias KtFunction<R> = (ArrayList<JsValue>) -> R ``` kotlin freeArena freeArena ========= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [freeArena](free-arena) **Platform and version requirements:** Native (1.3) ``` fun freeArena(arena: Arena) ``` kotlin setter setter ====== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / <setter> **Platform and version requirements:** Native (1.3) ``` fun setter(obj: JsValue, property: String, string: String) ``` ``` fun setter(     obj: JsValue,     property: String,     lambda: KtFunction<Unit>) ``` kotlin doubleLower doubleLower =========== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [doubleLower](double-lower) **Platform and version requirements:** Native (1.3) ``` fun doubleLower(value: Double): Int ``` kotlin allocateArena allocateArena ============= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [allocateArena](allocate-arena) **Platform and version requirements:** Native (1.3) ``` fun allocateArena(): Arena ``` **Retain** annotation is required to preserve functions from internalization and DCE. kotlin stringPointer stringPointer ============= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [stringPointer](string-pointer) **Platform and version requirements:** Native (1.3) ``` fun stringPointer(message: String): Pointer ``` kotlin pushIntToArena pushIntToArena ============== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [pushIntToArena](push-int-to-arena) **Platform and version requirements:** Native (1.3) ``` fun pushIntToArena(arena: Arena, value: Int) ``` kotlin Arena Arena ===== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [Arena](-arena) **Platform and version requirements:** Native (1.3) ``` typealias Arena = Int ``` kotlin Pointer Pointer ======= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [Pointer](-pointer) **Platform and version requirements:** Native (1.3) ``` typealias Pointer = Int ``` kotlin Object Object ====== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [Object](-object) **Platform and version requirements:** Native (1.3) ``` typealias Object = Int ``` kotlin doubleUpper doubleUpper =========== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [doubleUpper](double-upper) **Platform and version requirements:** Native (1.3) ``` fun doubleUpper(value: Double): Int ``` kotlin setFunction setFunction =========== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [setFunction](set-function) **Platform and version requirements:** Native (1.3) ``` fun setFunction(     arena: Arena,     obj: Object,     propertyName: Pointer,     propertyLength: Int,     function: Int) ``` kotlin ReturnSlot_getDouble ReturnSlot\_getDouble ===================== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [ReturnSlot\_getDouble](-return-slot_get-double) **Platform and version requirements:** Native (1.3) ``` fun ReturnSlot_getDouble(): Double ``` kotlin wrapFunction wrapFunction ============ [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [wrapFunction](wrap-function) **Platform and version requirements:** Native (1.3) ``` fun <R> wrapFunction(func: KtFunction<R>): Int ``` kotlin getInt getInt ====== [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [getInt](get-int) **Platform and version requirements:** Native (1.3) ``` fun getInt(     arena: Arena,     obj: Object,     propertyPtr: Pointer,     propertyLen: Int ): Int ``` kotlin runLambda runLambda ========= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [runLambda](run-lambda) **Platform and version requirements:** Native (1.3) ``` fun runLambda(     pointer: Int,     argumentsArena: Arena,     argumentsArenaSize: Int ): Int ``` kotlin setString setString ========= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [setString](set-string) **Platform and version requirements:** Native (1.3) ``` fun setString(     arena: Arena,     obj: Object,     propertyName: Pointer,     propertyLength: Int,     stringPtr: Pointer,     stringLength: Int) ``` kotlin upperWord upperWord ========= [kotlin-stdlib](../../../../../index) / [kotlinx.wasm.jsinterop](index) / [upperWord](upper-word) **Platform and version requirements:** Native (1.3) ``` const val upperWord: Long ```
programming_docs
kotlin ArenaManager ArenaManager ============ [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [ArenaManager](index) **Platform and version requirements:** Native (1.3) ``` object ArenaManager ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### [currentArena](current-arena) ``` var currentArena: Arena ``` **Platform and version requirements:** Native (1.3) #### [globalArena](global-arena) ``` val globalArena: Arena ``` kotlin currentArena currentArena ============ [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [ArenaManager](index) / [currentArena](current-arena) **Platform and version requirements:** Native (1.3) ``` var currentArena: Arena ``` kotlin globalArena globalArena =========== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [ArenaManager](index) / [globalArena](global-arena) **Platform and version requirements:** Native (1.3) ``` val globalArena: Arena ``` kotlin JsValue JsValue ======= [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) **Platform and version requirements:** Native (1.3) ``` open class JsValue ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` JsValue(arena: Arena, index: Object) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <arena> ``` val arena: Arena ``` **Platform and version requirements:** Native (1.3) #### [index](--index--) ``` val index: Object ``` Functions --------- **Platform and version requirements:** Native (1.3) #### [getInt](get-int) ``` fun getInt(property: String): Int ``` **Platform and version requirements:** Native (1.3) #### [getProperty](get-property) ``` fun getProperty(property: String): JsValue ``` Inheritors ---------- **Platform and version requirements:** Native (1.3) #### [JsArray](../-js-array/index) ``` open class JsArray : JsValue ``` kotlin getProperty getProperty =========== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) / [getProperty](get-property) **Platform and version requirements:** Native (1.3) ``` fun getProperty(property: String): JsValue ``` kotlin index index ===== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) / [index](--index--) **Platform and version requirements:** Native (1.3) ``` val index: Object ``` kotlin arena arena ===== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) / <arena> **Platform and version requirements:** Native (1.3) ``` val arena: Arena ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` JsValue(arena: Arena, index: Object) ``` kotlin getInt getInt ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsValue](index) / [getInt](get-int) **Platform and version requirements:** Native (1.3) ``` fun getInt(property: String): Int ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsArray](index) / <size> **Platform and version requirements:** Native (1.3) ``` val size: Int ``` kotlin JsArray JsArray ======= [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsArray](index) **Platform and version requirements:** Native (1.3) ``` open class JsArray : JsValue ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` JsArray(jsValue: JsValue) ``` ``` JsArray(arena: Arena, index: Object) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <size> ``` val size: Int ``` Functions --------- **Platform and version requirements:** Native (1.3) #### <get> ``` operator fun get(index: Int): JsValue ``` Extension Functions ------------------- **Platform and version requirements:** Native (1.3) #### [setter](../setter) ``` fun setter(     obj: JsValue,     property: String,     lambda: KtFunction<Unit>) ``` ``` fun setter(obj: JsValue, property: String, string: String) ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsArray](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` JsArray(jsValue: JsValue) ``` ``` JsArray(arena: Arena, index: Object) ``` kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlinx.wasm.jsinterop](../index) / [JsArray](index) / <get> **Platform and version requirements:** Native (1.3) ``` operator fun get(index: Int): JsValue ``` kotlin Package kotlin.io.path Package kotlin.io.path ====================== [kotlin-stdlib](../../../../../index) / [kotlin.io.path](index) Convenient extensions for working with file system using [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html). Types ----- **Platform and version requirements:** JVM (1.8), JRE7 (1.8) #### [CopyActionContext](-copy-action-context/index) Context for the `copyAction` function passed to [Path.copyToRecursively](java.nio.file.-path/copy-to-recursively). ``` interface CopyActionContext ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [CopyActionResult](-copy-action-result/index) The result of the `copyAction` function passed to [Path.copyToRecursively](java.nio.file.-path/copy-to-recursively) that specifies further actions when copying an entry. ``` enum class CopyActionResult ``` **Platform and version requirements:** JVM (1.7), JRE7 (1.7) #### [FileVisitorBuilder](-file-visitor-builder/index) The builder to provide implementation of the file visitor that [fileVisitor](file-visitor) builds. ``` sealed interface FileVisitorBuilder ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [OnErrorResult](-on-error-result/index) The result of the `onError` function passed to [Path.copyToRecursively](java.nio.file.-path/copy-to-recursively) that specifies further actions when an exception occurs. ``` enum class OnErrorResult ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [PathWalkOption](-path-walk-option/index) An enumeration to provide walk options for [Path.walk](java.nio.file.-path/walk) function. The options can be combined to form the walk order and behavior needed. ``` enum class PathWalkOption ``` Annotations ----------- **Platform and version requirements:** JVM (1.4), JRE7 (1.4) #### [ExperimentalPathApi](-experimental-path-api/index) This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. ``` annotation class ExperimentalPathApi ``` Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [java.net.URI](java.net.-u-r-i/index) **Platform and version requirements:** JVM (1.4), JRE7 (1.4) #### [java.nio.file.Path](java.nio.file.-path/index) Functions --------- **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createTempDirectory](create-temp-directory) Creates a new directory in the default temp directory, using the given [prefix](create-temp-directory#kotlin.io.path%24createTempDirectory(kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) to generate its name. ``` fun createTempDirectory(     prefix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates a new directory in the specified [directory](create-temp-directory#kotlin.io.path%24createTempDirectory(java.nio.file.Path?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/directory), using the given [prefix](create-temp-directory#kotlin.io.path%24createTempDirectory(java.nio.file.Path?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) to generate its name. ``` fun createTempDirectory(     directory: Path?,     prefix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createTempFile](create-temp-file) Creates an empty file in the default temp directory, using the given [prefix](create-temp-file#kotlin.io.path%24createTempFile(kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) and [suffix](create-temp-file#kotlin.io.path%24createTempFile(kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/suffix) to generate its name. ``` fun createTempFile(     prefix: String? = null,     suffix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates an empty file in the specified [directory](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/directory), using the given [prefix](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) and [suffix](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/suffix) to generate its name. ``` fun createTempFile(     directory: Path?,     prefix: String? = null,     suffix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.7), JRE7 (1.7) #### [fileVisitor](file-visitor) Builds a [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) whose implementation is defined in [builderAction](file-visitor#kotlin.io.path%24fileVisitor(kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction). ``` fun fileVisitor(     builderAction: FileVisitorBuilder.() -> Unit ): FileVisitor<Path> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [Path](-path) Converts the provided [path](-path#kotlin.io.path%24Path(kotlin.String)/path) string to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object of the [default](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystems.html#getDefault--) filesystem. ``` fun Path(path: String): Path ``` Converts the name sequence specified with the [base](-path#kotlin.io.path%24Path(kotlin.String,%20kotlin.Array((kotlin.String)))/base) path string and a number of [subpaths](-path#kotlin.io.path%24Path(kotlin.String,%20kotlin.Array((kotlin.String)))/subpaths) additional names to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object of the [default](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystems.html#getDefault--) filesystem. ``` fun Path(base: String, vararg subpaths: String): Path ``` kotlin Path Path ==== [kotlin-stdlib](../../../../../index) / [kotlin.io.path](index) / [Path](-path) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path(path: String): Path ``` Converts the provided [path](-path#kotlin.io.path%24Path(kotlin.String)/path) string to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object of the [default](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystems.html#getDefault--) filesystem. **See Also** [Paths.get](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html#get-java.lang.String-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path(base: String, vararg subpaths: String): Path ``` Converts the name sequence specified with the [base](-path#kotlin.io.path%24Path(kotlin.String,%20kotlin.Array((kotlin.String)))/base) path string and a number of [subpaths](-path#kotlin.io.path%24Path(kotlin.String,%20kotlin.Array((kotlin.String)))/subpaths) additional names to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object of the [default](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystems.html#getDefault--) filesystem. **See Also** [Paths.get](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html#get-java.lang.String-kotlin.Array-) kotlin createTempFile createTempFile ============== [kotlin-stdlib](../../../../../index) / [kotlin.io.path](index) / [createTempFile](create-temp-file) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun createTempFile(     prefix: String? = null,     suffix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates an empty file in the default temp directory, using the given [prefix](create-temp-file#kotlin.io.path%24createTempFile(kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) and [suffix](create-temp-file#kotlin.io.path%24createTempFile(kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/suffix) to generate its name. Parameters ---------- `attributes` - an optional list of file attributes to set atomically when creating the file. Exceptions ---------- `UnsupportedOperationException` - if the array contains an attribute that cannot be set atomically when creating the file. **Return** the path to the newly created file that did not exist before. **See Also** [Files.createTempFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createTempFile-java.nio.file.Path-java.lang.String-java.lang.String-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun createTempFile(     directory: Path?,     prefix: String? = null,     suffix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates an empty file in the specified [directory](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/directory), using the given [prefix](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) and [suffix](create-temp-file#kotlin.io.path%24createTempFile(java.nio.file.Path?,%20kotlin.String?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/suffix) to generate its name. Parameters ---------- `directory` - the parent directory in which to create a new file. It can be `null`, in that case the new file is created in the default temp directory. `attributes` - an optional list of file attributes to set atomically when creating the file. Exceptions ---------- `UnsupportedOperationException` - if the array contains an attribute that cannot be set atomically when creating the file. **Return** the path to the newly created file that did not exist before. **See Also** [Files.createTempFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createTempFile-java.nio.file.Path-java.lang.String-java.lang.String-kotlin.Array-) kotlin fileVisitor fileVisitor =========== [kotlin-stdlib](../../../../../index) / [kotlin.io.path](index) / [fileVisitor](file-visitor) **Platform and version requirements:** JVM (1.7), JRE7 (1.7) ``` @ExperimentalPathApi fun fileVisitor(     builderAction: FileVisitorBuilder.() -> Unit ): FileVisitor<Path> ``` Builds a [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) whose implementation is defined in [builderAction](file-visitor#kotlin.io.path%24fileVisitor(kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction). By default, the returned file visitor visits all files and re-throws I/O errors, that is: * [FileVisitor.preVisitDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#preVisitDirectory-java.nio.file.FileVisitor.T-java.nio.file.attribute.BasicFileAttributes-) returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE). * [FileVisitor.visitFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#visitFile-java.nio.file.FileVisitor.T-java.nio.file.attribute.BasicFileAttributes-) returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE). * [FileVisitor.visitFileFailed](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#visitFileFailed-java.nio.file.FileVisitor.T-java.io.IOException-) re-throws the I/O exception that prevented the file from being visited. * [FileVisitor.postVisitDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#postVisitDirectory-java.nio.file.FileVisitor.T-java.io.IOException-) returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE) if the directory iteration completes without an I/O exception; otherwise it re-throws the I/O exception that caused the iteration of the directory to terminate prematurely. To override a function provide its implementation to the corresponding function of the [FileVisitorBuilder](-file-visitor-builder/index) that was passed as a receiver to [builderAction](file-visitor#kotlin.io.path%24fileVisitor(kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction). Note that each function can be overridden only once. Repeated override of a function throws [IllegalStateException](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html). The builder is valid only inside [builderAction](file-visitor#kotlin.io.path%24fileVisitor(kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction) function. Using it outside the function throws [IllegalStateException](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html). Example: ``` val cleanVisitor = fileVisitor { onPreVisitDirectory { directory, _ -> if (directory.name == "build") { directory.toFile().deleteRecursively() FileVisitResult.SKIP_SUBTREE } else { FileVisitResult.CONTINUE } } onVisitFile { file, _ -> if (file.extension == "class") { file.deleteExisting() } FileVisitResult.CONTINUE } } ``` kotlin createTempDirectory createTempDirectory =================== [kotlin-stdlib](../../../../../index) / [kotlin.io.path](index) / [createTempDirectory](create-temp-directory) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun createTempDirectory(     prefix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates a new directory in the default temp directory, using the given [prefix](create-temp-directory#kotlin.io.path%24createTempDirectory(kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) to generate its name. Parameters ---------- `attributes` - an optional list of file attributes to set atomically when creating the directory. Exceptions ---------- `UnsupportedOperationException` - if the array contains an attribute that cannot be set atomically when creating the directory. **Return** the path to the newly created directory that did not exist before. **See Also** [Files.createTempDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createTempDirectory-java.nio.file.Path-java.lang.String-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun createTempDirectory(     directory: Path?,     prefix: String? = null,     vararg attributes: FileAttribute<*> ): Path ``` Creates a new directory in the specified [directory](create-temp-directory#kotlin.io.path%24createTempDirectory(java.nio.file.Path?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/directory), using the given [prefix](create-temp-directory#kotlin.io.path%24createTempDirectory(java.nio.file.Path?,%20kotlin.String?,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/prefix) to generate its name. Parameters ---------- `directory` - the parent directory in which to create a new directory. It can be `null`, in that case the new directory is created in the default temp directory. `attributes` - an optional list of file attributes to set atomically when creating the directory. Exceptions ---------- `UnsupportedOperationException` - if the array contains an attribute that cannot be set atomically when creating the directory. **Return** the path to the newly created directory that did not exist before. **See Also** [Files.createTempDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createTempDirectory-java.nio.file.Path-java.lang.String-kotlin.Array-)
programming_docs
kotlin SKIP_SUBTREE SKIP\_SUBTREE ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [OnErrorResult](index) / [SKIP\_SUBTREE](-s-k-i-p_-s-u-b-t-r-e-e) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` SKIP_SUBTREE ``` If the entry that caused the error is a directory, skip the directory and its content, and continue with the next entry outside this directory in the traversal order. Otherwise, skip this entry and continue with the next entry in the traversal order. kotlin OnErrorResult OnErrorResult ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [OnErrorResult](index) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` @ExperimentalPathApi enum class OnErrorResult ``` The result of the `onError` function passed to [Path.copyToRecursively](../java.nio.file.-path/copy-to-recursively) that specifies further actions when an exception occurs. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [SKIP\_SUBTREE](-s-k-i-p_-s-u-b-t-r-e-e) If the entry that caused the error is a directory, skip the directory and its content, and continue with the next entry outside this directory in the traversal order. Otherwise, skip this entry and continue with the next entry in the traversal order. **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [TERMINATE](-t-e-r-m-i-n-a-t-e) Stop the recursive copy function. The function will return without throwing exception. To terminate the function with an exception rethrow instead. kotlin TERMINATE TERMINATE ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [OnErrorResult](index) / [TERMINATE](-t-e-r-m-i-n-a-t-e) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` TERMINATE ``` Stop the recursive copy function. The function will return without throwing exception. To terminate the function with an exception rethrow instead. kotlin PathWalkOption PathWalkOption ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [PathWalkOption](index) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` @ExperimentalPathApi enum class PathWalkOption ``` An enumeration to provide walk options for [Path.walk](../java.nio.file.-path/walk) function. The options can be combined to form the walk order and behavior needed. Note that this enumeration is not exhaustive and new cases might be added in the future. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [INCLUDE\_DIRECTORIES](-i-n-c-l-u-d-e_-d-i-r-e-c-t-o-r-i-e-s) Visits directories as well. **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [BREADTH\_FIRST](-b-r-e-a-d-t-h_-f-i-r-s-t) Walks in breadth-first order. **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [FOLLOW\_LINKS](-f-o-l-l-o-w_-l-i-n-k-s) Follows symbolic links to the directories they point to. kotlin INCLUDE_DIRECTORIES INCLUDE\_DIRECTORIES ==================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [PathWalkOption](index) / [INCLUDE\_DIRECTORIES](-i-n-c-l-u-d-e_-d-i-r-e-c-t-o-r-i-e-s) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` INCLUDE_DIRECTORIES ``` Visits directories as well. kotlin FOLLOW_LINKS FOLLOW\_LINKS ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [PathWalkOption](index) / [FOLLOW\_LINKS](-f-o-l-l-o-w_-l-i-n-k-s) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` FOLLOW_LINKS ``` Follows symbolic links to the directories they point to. kotlin BREADTH_FIRST BREADTH\_FIRST ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [PathWalkOption](index) / [BREADTH\_FIRST](-b-r-e-a-d-t-h_-f-i-r-s-t) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` BREADTH_FIRST ``` Walks in breadth-first order. kotlin ExperimentalPathApi ExperimentalPathApi =================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [ExperimentalPathApi](index) **Platform and version requirements:** JVM (1.4), JRE7 (1.4) ``` @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 ExperimentalPathApi ``` This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. Beware using the annotated API especially if you're developing a library, since your library might become binary incompatible with the future versions of the standard library. Any usage of a declaration annotated with `@ExperimentalPathApi` must be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalPathApi::class)`, or by using the compiler argument `-opt-in=kotlin.io.path.ExperimentalPathApi`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [<init>](-init-) This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. ``` ExperimentalPathApi() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [ExperimentalPathApi](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` ExperimentalPathApi() ``` This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. Beware using the annotated API especially if you're developing a library, since your library might become binary incompatible with the future versions of the standard library. Any usage of a declaration annotated with `@ExperimentalPathApi` must be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalPathApi::class)`, or by using the compiler argument `-opt-in=kotlin.io.path.ExperimentalPathApi`. kotlin getPosixFilePermissions getPosixFilePermissions ======================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [getPosixFilePermissions](get-posix-file-permissions) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.getPosixFilePermissions(     vararg options: LinkOption ): Set<PosixFilePermission> ``` Returns the POSIX file permissions of the file located by this path. Exceptions ---------- `UnsupportedOperationException` - if the associated file system does not support the [PosixFileAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFileAttributeView.html). **See Also** [Files.getPosixFilePermissions](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getPosixFilePermissions-java.nio.file.Path-kotlin.Array-) kotlin forEachLine forEachLine =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [forEachLine](for-each-line) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` inline fun Path.forEachLine(     charset: Charset = Charsets.UTF_8,     action: (line: String) -> Unit) ``` Reads this file line by line using the specified [charset](for-each-line#kotlin.io.path%24forEachLine(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.String,%20kotlin.Unit)))/charset) and calls [action](for-each-line#kotlin.io.path%24forEachLine(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.String,%20kotlin.Unit)))/action) for each line. Default charset is UTF-8. You may use this function on huge files. Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. `action` - function to process file lines. kotlin isWritable isWritable ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isWritable](is-writable) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isWritable(): Boolean ``` Checks if the file located by this path exists and is writable. **See Also** [Files.isWritable](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isWritable-java.nio.file.Path-) kotlin deleteIfExists deleteIfExists ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [deleteIfExists](delete-if-exists) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.deleteIfExists(): Boolean ``` Deletes the file or empty directory specified by this path if it exists. Exceptions ---------- `DirectoryNotEmptyException` - if the directory exists but is not empty **Return** `true` if the existing file was successfully deleted, `false` if the file does not exist. **See Also** [Files.deleteIfExists](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#deleteIfExists-java.nio.file.Path-) kotlin setPosixFilePermissions setPosixFilePermissions ======================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [setPosixFilePermissions](set-posix-file-permissions) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.setPosixFilePermissions(     value: Set<PosixFilePermission> ): Path ``` Sets the POSIX file permissions for the file located by this path. Exceptions ---------- `UnsupportedOperationException` - if the associated file system does not support the [PosixFileAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/PosixFileAttributeView.html). **See Also** [Files.setPosixFilePermissions](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#setPosixFilePermissions-java.nio.file.Path-java.util.Set-) kotlin isSymbolicLink isSymbolicLink ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isSymbolicLink](is-symbolic-link) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isSymbolicLink(): Boolean ``` Checks if the file located by this path exists and is a symbolic link. **See Also** [Files.isSymbolicLink](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isSymbolicLink-java.nio.file.Path-) kotlin deleteExisting deleteExisting ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [deleteExisting](delete-existing) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.deleteExisting() ``` Deletes the existing file or empty directory specified by this path. Exceptions ---------- `NoSuchFileException` - if the file or directory does not exist. `DirectoryNotEmptyException` - if the directory exists but is not empty. **See Also** [Files.delete](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#delete-java.nio.file.Path-) kotlin bufferedWriter bufferedWriter ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [bufferedWriter](buffered-writer) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.bufferedWriter(     charset: Charset = Charsets.UTF_8,     bufferSize: Int = DEFAULT_BUFFER_SIZE,     vararg options: OpenOption ): BufferedWriter ``` Returns a new [BufferedWriter](https://docs.oracle.com/javase/8/docs/api/java/io/BufferedWriter.html) for writing the content of this file. Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default. `bufferSize` - necessary size of the buffer. `options` - options to determine how the file is opened. kotlin extension extension ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <extension> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` val Path.extension: String ``` Returns the extension of this path (not including the dot), or an empty string if it doesn't have one. kotlin getOwner getOwner ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [getOwner](get-owner) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.getOwner(vararg options: LinkOption): UserPrincipal? ``` Returns the owner of a file. Exceptions ---------- `UnsupportedOperationException` - if the associated file system does not support the [FileOwnerAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/FileOwnerAttributeView.html). **See Also** [Files.getOwner](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getOwner-java.nio.file.Path-kotlin.Array-) kotlin exists exists ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <exists> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.exists(vararg options: LinkOption): Boolean ``` Checks if the file located by this path exists. Parameters ---------- `options` - options to control how symbolic links are handled. **Return** `true`, if the file definitely exists, `false` otherwise, including situations when the existence cannot be determined. **See Also** [Files.exists](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#exists-java.nio.file.Path-kotlin.Array-) kotlin bufferedReader bufferedReader ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [bufferedReader](buffered-reader) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.bufferedReader(     charset: Charset = Charsets.UTF_8,     bufferSize: Int = DEFAULT_BUFFER_SIZE,     vararg options: OpenOption ): BufferedReader ``` Returns a new [BufferedReader](https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html) for reading the content of this file. Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. `bufferSize` - necessary size of the buffer. `options` - options to determine how the file is opened. kotlin deleteRecursively deleteRecursively ================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [deleteRecursively](delete-recursively) **Platform and version requirements:** JVM (1.8), JRE7 (1.8) ``` @ExperimentalPathApi fun Path.deleteRecursively() ``` Recursively deletes this directory and its content. Note that if this function throws, partial deletion may have taken place. If the entry located by this path is a directory, this function recursively deletes its content and the directory itself. Otherwise, this function deletes only the entry. Symbolic links are not followed to their targets. This function does nothing if the entry located by this path does not exist. If the underlying platform supports [SecureDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/SecureDirectoryStream.html), traversal of the file tree and removal of entries are performed using it. Otherwise, directories in the file tree are opened with the less secure [Files.newDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newDirectoryStream-java.nio.file.Path-). Note that on a platform that supports symbolic links and does not support [SecureDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/SecureDirectoryStream.html), it is possible for a recursive delete to delete files and directories that are outside the directory being deleted. This can happen if, after checking that an entry is a directory (and not a symbolic link), that directory is replaced by a symbolic link to an outside directory before the call that opens the directory to read its entries. If an exception occurs attempting to read, open or delete any entry under the given file tree, this method skips that entry and continues. Such exceptions are collected and, after attempting to delete all entries, an [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html) is thrown containing those exceptions as suppressed exceptions. Maximum of `64` exceptions are collected. After reaching that amount, thrown exceptions are ignored and not collected. Exceptions ---------- `IOException` - if any entry in the file tree can't be deleted for any reason. kotlin Extensions for java.nio.file.Path Extensions for java.nio.file.Path ================================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <absolute> Converts this possibly relative path to an absolute path. ``` fun Path.absolute(): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [absolutePathString](absolute-path-string) Converts this possibly relative path to an absolute path and returns its string representation. ``` fun Path.absolutePathString(): String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [appendBytes](append-bytes) Appends an [array](append-bytes#kotlin.io.path%24appendBytes(java.nio.file.Path,%20kotlin.ByteArray)/array) of bytes to the content of this file. ``` fun Path.appendBytes(array: ByteArray) ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [appendLines](append-lines) Appends the specified collection of char sequences [lines](append-lines#kotlin.io.path%24appendLines(java.nio.file.Path,%20kotlin.collections.Iterable((kotlin.CharSequence)),%20java.nio.charset.Charset)/lines) to a file terminating each one with the platform's line separator. ``` fun Path.appendLines(     lines: Iterable<CharSequence>,     charset: Charset = Charsets.UTF_8 ): Path ``` Appends the specified sequence of char sequences [lines](append-lines#kotlin.io.path%24appendLines(java.nio.file.Path,%20kotlin.sequences.Sequence((kotlin.CharSequence)),%20java.nio.charset.Charset)/lines) to a file terminating each one with the platform's line separator. ``` fun Path.appendLines(     lines: Sequence<CharSequence>,     charset: Charset = Charsets.UTF_8 ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [appendText](append-text) Appends [text](append-text#kotlin.io.path%24appendText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset)/text) to the content of this file using UTF-8 or the specified [charset](append-text#kotlin.io.path%24appendText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset)/charset). ``` fun Path.appendText(     text: CharSequence,     charset: Charset = Charsets.UTF_8) ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [bufferedReader](buffered-reader) Returns a new [BufferedReader](https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html) for reading the content of this file. ``` fun Path.bufferedReader(     charset: Charset = Charsets.UTF_8,     bufferSize: Int = DEFAULT_BUFFER_SIZE,     vararg options: OpenOption ): BufferedReader ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [bufferedWriter](buffered-writer) Returns a new [BufferedWriter](https://docs.oracle.com/javase/8/docs/api/java/io/BufferedWriter.html) for writing the content of this file. ``` fun Path.bufferedWriter(     charset: Charset = Charsets.UTF_8,     bufferSize: Int = DEFAULT_BUFFER_SIZE,     vararg options: OpenOption ): BufferedWriter ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [copyTo](copy-to) Copies a file or directory located by this path to the given [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path. ``` fun Path.copyTo(     target: Path,     overwrite: Boolean = false ): Path ``` ``` fun Path.copyTo(     target: Path,     vararg options: CopyOption ): Path ``` **Platform and version requirements:** JVM (1.8), JRE7 (1.8) #### [copyToRecursively](copy-to-recursively) Recursively copies this directory and its content to the specified destination [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/target) path. Note that if this function throws, partial copying may have taken place. ``` fun Path.copyToRecursively(     target: Path,     onError: (source: Path, target: Path, exception: Exception) -> OnErrorResult = { _, _, exception -> throw exception },     followLinks: Boolean,     overwrite: Boolean ): Path ``` ``` fun Path.copyToRecursively(     target: Path,     onError: (source: Path, target: Path, exception: Exception) -> OnErrorResult = { _, _, exception -> throw exception },     followLinks: Boolean,     copyAction: CopyActionContext.(source: Path, target: Path) -> CopyActionResult = { src, dst -> src.copyToIgnoringExistingDirectory(dst, followLinks) } ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createDirectories](create-directories) Creates a directory ensuring that all nonexistent parent directories exist by creating them first. ``` fun Path.createDirectories(     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createDirectory](create-directory) Creates a new directory or throws an exception if there is already a file or directory located by this path. ``` fun Path.createDirectory(     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createFile](create-file) Creates a new and empty file specified by this path, failing if the file already exists. ``` fun Path.createFile(     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createLinkPointingTo](create-link-pointing-to) Creates a new link (directory entry) located by this path for the existing file [target](create-link-pointing-to#kotlin.io.path%24createLinkPointingTo(java.nio.file.Path,%20java.nio.file.Path)/target). ``` fun Path.createLinkPointingTo(target: Path): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [createSymbolicLinkPointingTo](create-symbolic-link-pointing-to) Creates a new symbolic link located by this path to the given [target](create-symbolic-link-pointing-to#kotlin.io.path%24createSymbolicLinkPointingTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/target). ``` fun Path.createSymbolicLinkPointingTo(     target: Path,     vararg attributes: FileAttribute<*> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [deleteExisting](delete-existing) Deletes the existing file or empty directory specified by this path. ``` fun Path.deleteExisting() ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [deleteIfExists](delete-if-exists) Deletes the file or empty directory specified by this path if it exists. ``` fun Path.deleteIfExists(): Boolean ``` **Platform and version requirements:** JVM (1.8), JRE7 (1.8) #### [deleteRecursively](delete-recursively) Recursively deletes this directory and its content. Note that if this function throws, partial deletion may have taken place. ``` fun Path.deleteRecursively() ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <div> Resolves the given [other](div#kotlin.io.path%24div(java.nio.file.Path,%20java.nio.file.Path)/other) path against this path. ``` operator fun Path.div(other: Path): Path ``` Resolves the given [other](div#kotlin.io.path%24div(java.nio.file.Path,%20kotlin.String)/other) path string against this path. ``` operator fun Path.div(other: String): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <exists> Checks if the file located by this path exists. ``` fun Path.exists(vararg options: LinkOption): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <extension> Returns the extension of this path (not including the dot), or an empty string if it doesn't have one. ``` val Path.extension: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [fileAttributesView](file-attributes-view) Returns a file attributes view of a given type [V](file-attributes-view#V) or throws an [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) if the requested attribute view type is not available.. ``` fun <V : FileAttributeView> Path.fileAttributesView(     vararg options: LinkOption ): V ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [fileAttributesViewOrNull](file-attributes-view-or-null) Returns a file attributes view of a given type [V](file-attributes-view-or-null#V) or `null` if the requested attribute view type is not available. ``` fun <V : FileAttributeView> Path.fileAttributesViewOrNull(     vararg options: LinkOption ): V? ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [fileSize](file-size) Returns the size of a regular file as a Long value of bytes or throws an exception if the file doesn't exist. ``` fun Path.fileSize(): Long ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [fileStore](file-store) Returns the [FileStore](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileStore.html) representing the file store where a file is located. ``` fun Path.fileStore(): FileStore ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [forEachDirectoryEntry](for-each-directory-entry) Performs the given [action](for-each-directory-entry#kotlin.io.path%24forEachDirectoryEntry(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((java.nio.file.Path,%20kotlin.Unit)))/action) on each entry in this directory optionally filtered by matching against the specified [glob](for-each-directory-entry#kotlin.io.path%24forEachDirectoryEntry(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((java.nio.file.Path,%20kotlin.Unit)))/glob) pattern. ``` fun Path.forEachDirectoryEntry(     glob: String = "*",     action: (Path) -> Unit) ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [forEachLine](for-each-line) Reads this file line by line using the specified [charset](for-each-line#kotlin.io.path%24forEachLine(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.String,%20kotlin.Unit)))/charset) and calls [action](for-each-line#kotlin.io.path%24forEachLine(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.String,%20kotlin.Unit)))/action) for each line. Default charset is UTF-8. ``` fun Path.forEachLine(     charset: Charset = Charsets.UTF_8,     action: (line: String) -> Unit) ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [getAttribute](get-attribute) Reads the value of a file attribute. ``` fun Path.getAttribute(     attribute: String,     vararg options: LinkOption ): Any? ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [getLastModifiedTime](get-last-modified-time) Returns the last modified time of the file located by this path. ``` fun Path.getLastModifiedTime(     vararg options: LinkOption ): FileTime ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [getOwner](get-owner) Returns the owner of a file. ``` fun Path.getOwner(vararg options: LinkOption): UserPrincipal? ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [getPosixFilePermissions](get-posix-file-permissions) Returns the POSIX file permissions of the file located by this path. ``` fun Path.getPosixFilePermissions(     vararg options: LinkOption ): Set<PosixFilePermission> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [inputStream](input-stream) Constructs a new InputStream of this file and returns it as a result. ``` fun Path.inputStream(vararg options: OpenOption): InputStream ``` **Platform and version requirements:** JVM (1.4), JRE7 (1.4) #### [invariantSeparatorsPath](invariant-separators-path) ``` val Path.invariantSeparatorsPath: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [invariantSeparatorsPathString](invariant-separators-path-string) Returns the string representation of this path using the invariant separator '/' to separate names in the path. ``` val Path.invariantSeparatorsPathString: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isDirectory](is-directory) Checks if the file located by this path is a directory. ``` fun Path.isDirectory(vararg options: LinkOption): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isExecutable](is-executable) Checks if the file located by this path exists and is executable. ``` fun Path.isExecutable(): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isHidden](is-hidden) Checks if the file located by this path is considered hidden. ``` fun Path.isHidden(): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isReadable](is-readable) Checks if the file located by this path exists and is readable. ``` fun Path.isReadable(): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isRegularFile](is-regular-file) Checks if the file located by this path is a regular file. ``` fun Path.isRegularFile(vararg options: LinkOption): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isSameFileAs](is-same-file-as) Checks if the file located by this path points to the same file or directory as [other](is-same-file-as#kotlin.io.path%24isSameFileAs(java.nio.file.Path,%20java.nio.file.Path)/other). ``` fun Path.isSameFileAs(other: Path): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isSymbolicLink](is-symbolic-link) Checks if the file located by this path exists and is a symbolic link. ``` fun Path.isSymbolicLink(): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [isWritable](is-writable) Checks if the file located by this path exists and is writable. ``` fun Path.isWritable(): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [listDirectoryEntries](list-directory-entries) Returns a list of the entries in this directory optionally filtered by matching against the specified [glob](list-directory-entries#kotlin.io.path%24listDirectoryEntries(java.nio.file.Path,%20kotlin.String)/glob) pattern. ``` fun Path.listDirectoryEntries(glob: String = "*"): List<Path> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [moveTo](move-to) Moves or renames the file located by this path to the [target](move-to#kotlin.io.path%24moveTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) path. ``` fun Path.moveTo(     target: Path,     vararg options: CopyOption ): Path ``` ``` fun Path.moveTo(     target: Path,     overwrite: Boolean = false ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <name> Returns the name of the file or directory denoted by this path as a string, or an empty string if this path has zero path elements. ``` val Path.name: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [nameWithoutExtension](name-without-extension) Returns the <name> of this file or directory without an extension, or an empty string if this path has zero path elements. ``` val Path.nameWithoutExtension: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [notExists](not-exists) Checks if the file located by this path does not exist. ``` fun Path.notExists(vararg options: LinkOption): Boolean ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [outputStream](output-stream) Constructs a new OutputStream of this file and returns it as a result. ``` fun Path.outputStream(     vararg options: OpenOption ): OutputStream ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [pathString](path-string) Returns the string representation of this path. ``` val Path.pathString: String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [readAttributes](read-attributes) Reads a file's attributes of the specified type [A](read-attributes#A) in bulk. ``` fun <A : BasicFileAttributes> Path.readAttributes(     vararg options: LinkOption ): A ``` Reads the specified list of attributes of a file in bulk. ``` fun Path.readAttributes(     attributes: String,     vararg options: LinkOption ): Map<String, Any?> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [readBytes](read-bytes) Gets the entire content of this file as a byte array. ``` fun Path.readBytes(): ByteArray ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <reader> Returns a new [InputStreamReader](https://docs.oracle.com/javase/8/docs/api/java/io/InputStreamReader.html) for reading the content of this file. ``` fun Path.reader(     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): InputStreamReader ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [readLines](read-lines) Reads the file content as a list of lines. ``` fun Path.readLines(     charset: Charset = Charsets.UTF_8 ): List<String> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [readSymbolicLink](read-symbolic-link) Reads the target of a symbolic link located by this path. ``` fun Path.readSymbolicLink(): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [readText](read-text) Gets the entire content of this file as a String using UTF-8 or the specified [charset](read-text#kotlin.io.path%24readText(java.nio.file.Path,%20java.nio.charset.Charset)/charset). ``` fun Path.readText(charset: Charset = Charsets.UTF_8): String ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [relativeTo](relative-to) Calculates the relative path for this path from a [base](relative-to#kotlin.io.path%24relativeTo(java.nio.file.Path,%20java.nio.file.Path)/base) path. ``` fun Path.relativeTo(base: Path): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [relativeToOrNull](relative-to-or-null) Calculates the relative path for this path from a [base](relative-to-or-null#kotlin.io.path%24relativeToOrNull(java.nio.file.Path,%20java.nio.file.Path)/base) path. ``` fun Path.relativeToOrNull(base: Path): Path? ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [relativeToOrSelf](relative-to-or-self) Calculates the relative path for this path from a [base](relative-to-or-self#kotlin.io.path%24relativeToOrSelf(java.nio.file.Path,%20java.nio.file.Path)/base) path. ``` fun Path.relativeToOrSelf(base: Path): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [setAttribute](set-attribute) Sets the value of a file attribute. ``` fun Path.setAttribute(     attribute: String,     value: Any?,     vararg options: LinkOption ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [setLastModifiedTime](set-last-modified-time) Sets the last modified time attribute for the file located by this path. ``` fun Path.setLastModifiedTime(value: FileTime): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [setOwner](set-owner) Sets the file owner to the specified [value](set-owner#kotlin.io.path%24setOwner(java.nio.file.Path,%20java.nio.file.attribute.UserPrincipal)/value). ``` fun Path.setOwner(value: UserPrincipal): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [setPosixFilePermissions](set-posix-file-permissions) Sets the POSIX file permissions for the file located by this path. ``` fun Path.setPosixFilePermissions(     value: Set<PosixFilePermission> ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [useDirectoryEntries](use-directory-entries) Calls the [block](use-directory-entries#kotlin.io.path%24useDirectoryEntries(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((kotlin.sequences.Sequence((java.nio.file.Path)),%20kotlin.io.path.useDirectoryEntries.T)))/block) callback with a sequence of all entries in this directory optionally filtered by matching against the specified [glob](use-directory-entries#kotlin.io.path%24useDirectoryEntries(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((kotlin.sequences.Sequence((java.nio.file.Path)),%20kotlin.io.path.useDirectoryEntries.T)))/glob) pattern. ``` fun <T> Path.useDirectoryEntries(     glob: String = "*",     block: (Sequence<Path>) -> T ): T ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [useLines](use-lines) Calls the [block](use-lines#kotlin.io.path%24useLines(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.sequences.Sequence((kotlin.String)),%20kotlin.io.path.useLines.T)))/block) callback giving it a sequence of all the lines in this file and closes the reader once the processing is complete. ``` fun <T> Path.useLines(     charset: Charset = Charsets.UTF_8,     block: (Sequence<String>) -> T ): T ``` **Platform and version requirements:** JVM (1.7), JRE7 (1.7) #### [visitFileTree](visit-file-tree) Visits this directory and all its content with the specified [visitor](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20java.nio.file.FileVisitor((java.nio.file.Path)),%20kotlin.Int,%20kotlin.Boolean)/visitor). ``` fun Path.visitFileTree(     visitor: FileVisitor<Path>,     maxDepth: Int = Int.MAX_VALUE,     followLinks: Boolean = false) ``` Visits this directory and all its content with the [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) defined in [builderAction](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction). ``` fun Path.visitFileTree(     maxDepth: Int = Int.MAX_VALUE,     followLinks: Boolean = false,     builderAction: FileVisitorBuilder.() -> Unit) ``` **Platform and version requirements:** JVM (1.7), JRE7 (1.7) #### <walk> Returns a sequence of paths for visiting this directory and all its content. ``` fun Path.walk(vararg options: PathWalkOption): Sequence<Path> ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [writeBytes](write-bytes) Writes an [array](write-bytes#kotlin.io.path%24writeBytes(java.nio.file.Path,%20kotlin.ByteArray,%20kotlin.Array((java.nio.file.OpenOption)))/array) of bytes to this file. ``` fun Path.writeBytes(     array: ByteArray,     vararg options: OpenOption) ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [writeLines](write-lines) Write the specified collection of char sequences [lines](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.collections.Iterable((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/lines) to a file terminating each one with the platform's line separator. ``` fun Path.writeLines(     lines: Iterable<CharSequence>,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): Path ``` Write the specified sequence of char sequences [lines](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.sequences.Sequence((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/lines) to a file terminating each one with the platform's line separator. ``` fun Path.writeLines(     lines: Sequence<CharSequence>,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): Path ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### <writer> Returns a new [OutputStreamWriter](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStreamWriter.html) for writing the content of this file. ``` fun Path.writer(     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): OutputStreamWriter ``` **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [writeText](write-text) Sets the content of this file as [text](write-text#kotlin.io.path%24writeText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/text) encoded using UTF-8 or the specified [charset](write-text#kotlin.io.path%24writeText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/charset). ``` fun Path.writeText(     text: CharSequence,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption) ```
programming_docs
kotlin writeText writeText ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [writeText](write-text) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.writeText(     text: CharSequence,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption) ``` Sets the content of this file as [text](write-text#kotlin.io.path%24writeText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/text) encoded using UTF-8 or the specified [charset](write-text#kotlin.io.path%24writeText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/charset). By default, the file will be overwritten if it already exists, but you can control this behavior with [options](write-text#kotlin.io.path%24writeText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/options). Parameters ---------- `text` - text to write into file. `charset` - character set to use for writing text, UTF-8 by default. `options` - options to determine how the file is opened. kotlin moveTo moveTo ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [moveTo](move-to) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.moveTo(     target: Path,     vararg options: CopyOption ): Path ``` Moves or renames the file located by this path to the [target](move-to#kotlin.io.path%24moveTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) path. Parameters ---------- `options` - options specifying how the move should be done, see [StandardCopyOption](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html), [LinkOption](https://docs.oracle.com/javase/8/docs/api/java/nio/file/LinkOption.html). Exceptions ---------- `FileAlreadyExistsException` - if the target file exists but cannot be replaced because the [StandardCopyOption.REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) option is not specified (optional specific exception). `DirectoryNotEmptyException` - the [StandardCopyOption.REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) option is specified but the file cannot be replaced because it is a non-empty directory, or the source is a non-empty directory containing entries that would be required to be moved (optional specific exception). **See Also** [Files.move](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#move-java.nio.file.Path-java.nio.file.Path-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.moveTo(     target: Path,     overwrite: Boolean = false ): Path ``` Moves or renames the file located by this path to the [target](move-to#kotlin.io.path%24moveTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path. Parameters ---------- `overwrite` - allows to overwrite the target if it already exists. Exceptions ---------- `FileAlreadyExistsException` - if the target file exists but cannot be replaced because the `overwrite = true` option is not specified (optional specific exception). `DirectoryNotEmptyException` - the `overwrite = true` option is specified but the file cannot be replaced because it is a non-empty directory, or the source is a non-empty directory containing entries that would be required to be moved (optional specific exception). **See Also** [Files.move](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#move-java.nio.file.Path-java.nio.file.Path-kotlin.Array-) kotlin fileAttributesViewOrNull fileAttributesViewOrNull ======================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [fileAttributesViewOrNull](file-attributes-view-or-null) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun <reified V : FileAttributeView> Path.fileAttributesViewOrNull(     vararg options: LinkOption ): V? ``` Returns a file attributes view of a given type [V](file-attributes-view-or-null#V) or `null` if the requested attribute view type is not available. The returned view allows to read and optionally to modify attributes of a file. Parameters ---------- `V` - the reified type of the desired attribute view. **See Also** [Files.getFileAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getFileAttributeView-java.nio.file.Path-java.lang.Class-kotlin.Array-) kotlin isDirectory isDirectory =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isDirectory](is-directory) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isDirectory(vararg options: LinkOption): Boolean ``` Checks if the file located by this path is a directory. By default, symbolic links in the path are followed. Parameters ---------- `options` - options to control how symbolic links are handled. **See Also** [Files.isDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isDirectory-java.nio.file.Path-kotlin.Array-) kotlin createFile createFile ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [createFile](create-file) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.createFile(     vararg attributes: FileAttribute<*> ): Path ``` Creates a new and empty file specified by this path, failing if the file already exists. Parameters ---------- `attributes` - an optional list of file attributes to set atomically when creating the file. Exceptions ---------- `FileAlreadyExistsException` - if a file specified by this path already exists (optional specific exception, some implementations may throw more general [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html)). `UnsupportedOperationException` - if the [attributes](create-file#kotlin.io.path%24createFile(java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/attributes) array contains an attribute that cannot be set atomically when creating the file. **See Also** [Files.createFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createFile-java.nio.file.Path-kotlin.Array-) kotlin relativeTo relativeTo ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [relativeTo](relative-to) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.relativeTo(base: Path): Path ``` Calculates the relative path for this path from a [base](relative-to#kotlin.io.path%24relativeTo(java.nio.file.Path,%20java.nio.file.Path)/base) path. Note that the [base](relative-to#kotlin.io.path%24relativeTo(java.nio.file.Path,%20java.nio.file.Path)/base) path is treated as a directory. If this path matches the [base](relative-to#kotlin.io.path%24relativeTo(java.nio.file.Path,%20java.nio.file.Path)/base) path, then a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) with an empty path will be returned. Exceptions ---------- `IllegalArgumentException` - if this and base paths have different roots. **Return** the relative path from [base](relative-to#kotlin.io.path%24relativeTo(java.nio.file.Path,%20java.nio.file.Path)/base) to this. kotlin writer writer ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <writer> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.writer(     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): OutputStreamWriter ``` Returns a new [OutputStreamWriter](https://docs.oracle.com/javase/8/docs/api/java/io/OutputStreamWriter.html) for writing the content of this file. Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default. `options` - options to determine how the file is opened. kotlin setOwner setOwner ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [setOwner](set-owner) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.setOwner(value: UserPrincipal): Path ``` Sets the file owner to the specified [value](set-owner#kotlin.io.path%24setOwner(java.nio.file.Path,%20java.nio.file.attribute.UserPrincipal)/value). Exceptions ---------- `UnsupportedOperationException` - if the associated file system does not support the [FileOwnerAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/FileOwnerAttributeView.html). **See Also** [Files.setOwner](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#setOwner-java.nio.file.Path-java.nio.file.attribute.UserPrincipal-) kotlin notExists notExists ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [notExists](not-exists) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.notExists(vararg options: LinkOption): Boolean ``` Checks if the file located by this path does not exist. Parameters ---------- `options` - options to control how symbolic links are handled. **Return** `true`, if the file definitely does not exist, `false` otherwise, including situations when the existence cannot be determined. **See Also** [Files.notExists](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#notExists-java.nio.file.Path-kotlin.Array-) kotlin copyToRecursively copyToRecursively ================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [copyToRecursively](copy-to-recursively) **Platform and version requirements:** JVM (1.8), JRE7 (1.8) ``` @ExperimentalPathApi fun Path.copyToRecursively(     target: Path,     onError: (source: Path, target: Path, exception: Exception) -> OnErrorResult = { _, _, exception -> throw exception },     followLinks: Boolean,     overwrite: Boolean ): Path ``` Recursively copies this directory and its content to the specified destination [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/target) path. Note that if this function throws, partial copying may have taken place. Unlike `File.copyRecursively`, if some directories on the way to the [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/target) are missing, then they won't be created automatically. You can use the following approach to ensure that required intermediate directories are created: ``` sourcePath.copyToRecursively( destinationPath.apply { parent?.createDirectories() }, followLinks = false ) ``` If the entry located by this path is a directory, this function recursively copies the directory itself and its content. Otherwise, this function copies only the entry. If an exception occurs attempting to read, open or copy any entry under the source subtree, further actions will depend on the result of the [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) invoked with the source and destination paths, that caused the error, and the exception itself as arguments. If [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) throws, this function ends immediately with the exception. By default [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) rethrows the exception. See [OnErrorResult](../-on-error-result/index) for available options. This function performs "directory merge" operation. If an entry in the source subtree is a directory and the corresponding entry in the target subtree already exists and is also a directory, it does nothing. Otherwise, [overwrite](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/overwrite) determines whether to overwrite existing destination entries. Attributes of a source entry, such as creation/modification date, are not copied. [followLinks](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/followLinks) determines whether to copy a symbolic link itself or its target. Symbolic links in the target subtree are not followed. To provide a custom logic for copying use the overload that takes a `copyAction` lambda. Parameters ---------- `target` - the destination path to copy recursively this entry to. `onError` - the function that determines further actions if an error occurs. By default, rethrows the exception. `followLinks` - `false` to copy a symbolic link itself, not its target. `true` to recursively copy the target of a symbolic link. `overwrite` - `false` to throw if a destination entry already exists. `true` to overwrite existing destination entries. Exceptions ---------- `NoSuchFileException` - if the entry located by this path does not exist. `FileSystemException` - if [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/target) is an entry inside the source subtree. `FileAlreadyExistsException` - if a destination entry already exists and [overwrite](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/overwrite) is `false`. This exception is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) for handling. `IOException` - if any errors occur while copying. This exception is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) for handling. `SecurityException` - if a security manager is installed and access is not permitted to an entry in the source or target subtree. This exception is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Boolean)/onError) for handling. **Platform and version requirements:** JVM (1.8), JRE7 (1.8) ``` @ExperimentalPathApi fun Path.copyToRecursively(     target: Path,     onError: (source: Path, target: Path, exception: Exception) -> OnErrorResult = { _, _, exception -> throw exception },     followLinks: Boolean,     copyAction: CopyActionContext.(source: Path, target: Path) -> CopyActionResult = { src, dst -> src.copyToIgnoringExistingDirectory(dst, followLinks) } ): Path ``` Recursively copies this directory and its content to the specified destination [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/target) path. Note that if this function throws, partial copying may have taken place. Unlike `File.copyRecursively`, if some directories on the way to the [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/target) are missing, then they won't be created automatically. You can use the following approach to ensure that required intermediate directories are created: ``` sourcePath.copyToRecursively( destinationPath.apply { parent?.createDirectories() }, followLinks = false ) ``` If the entry located by this path is a directory, this function recursively copies the directory itself and its content. Otherwise, this function copies only the entry. If an exception occurs attempting to read, open or copy any entry under the source subtree, further actions will depend on the result of the [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) invoked with the source and destination paths, that caused the error, and the exception itself as arguments. If [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) throws, this function ends immediately with the exception. By default [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) rethrows the exception. See [OnErrorResult](../-on-error-result/index) for available options. Copy operation is performed using [copyAction](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/copyAction). By default [copyAction](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/copyAction) performs "directory merge" operation. If an entry in the source subtree is a directory and the corresponding entry in the target subtree already exists and is also a directory, it does nothing. Otherwise, the entry is copied using `sourcePath.copyTo(destinationPath, *followLinksOption)`, which doesn't copy attributes of the source entry and throws if the destination entry already exists. [followLinks](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/followLinks) determines whether to copy a symbolic link itself or its target. Symbolic links in the target subtree are not followed. If a custom implementation of [copyAction](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/copyAction) is provided, consider making it consistent with [followLinks](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/followLinks) value. See [CopyActionResult](../-copy-action-result/index) for available options. If [copyAction](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/copyAction) throws an exception, it is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) for handling. Parameters ---------- `target` - the destination path to copy recursively this entry to. `onError` - the function that determines further actions if an error occurs. By default, rethrows the exception. `followLinks` - `false` to copy a symbolic link itself, not its target. `true` to recursively copy the target of a symbolic link. `copyAction` - the function to call for copying source entries to their destination path rooted in [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/target). By default, performs "directory merge" operation. Exceptions ---------- `NoSuchFileException` - if the entry located by this path does not exist. `FileSystemException` - if [target](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/target) is an entry inside the source subtree. `IOException` - if any errors occur while copying. This exception is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) for handling. `SecurityException` - if a security manager is installed and access is not permitted to an entry in the source or target subtree. This exception is passed to [onError](copy-to-recursively#kotlin.io.path%24copyToRecursively(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Function3((java.nio.file.Path,%20,%20java.lang.Exception,%20kotlin.io.path.OnErrorResult)),%20kotlin.Boolean,%20kotlin.Function3((kotlin.io.path.CopyActionContext,%20java.nio.file.Path,%20,%20kotlin.io.path.CopyActionResult)))/onError) for handling.
programming_docs
kotlin useDirectoryEntries useDirectoryEntries =================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [useDirectoryEntries](use-directory-entries) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` inline fun <T> Path.useDirectoryEntries(     glob: String = "*",     block: (Sequence<Path>) -> T ): T ``` Calls the [block](use-directory-entries#kotlin.io.path%24useDirectoryEntries(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((kotlin.sequences.Sequence((java.nio.file.Path)),%20kotlin.io.path.useDirectoryEntries.T)))/block) callback with a sequence of all entries in this directory optionally filtered by matching against the specified [glob](use-directory-entries#kotlin.io.path%24useDirectoryEntries(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((kotlin.sequences.Sequence((java.nio.file.Path)),%20kotlin.io.path.useDirectoryEntries.T)))/glob) pattern. Parameters ---------- `glob` - the globbing pattern. The syntax is specified by the [FileSystem.getPathMatcher](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-) method. Exceptions ---------- `java.util.regex.PatternSyntaxException` - if the glob pattern is invalid. `NotDirectoryException` - If this path does not refer to a directory. `IOException` - If an I/O error occurs. **Return** the value returned by [block](use-directory-entries#kotlin.io.path%24useDirectoryEntries(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((kotlin.sequences.Sequence((java.nio.file.Path)),%20kotlin.io.path.useDirectoryEntries.T)))/block). **See Also** [Files.newDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newDirectoryStream-java.nio.file.Path-) kotlin appendText appendText ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [appendText](append-text) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.appendText(     text: CharSequence,     charset: Charset = Charsets.UTF_8) ``` Appends [text](append-text#kotlin.io.path%24appendText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset)/text) to the content of this file using UTF-8 or the specified [charset](append-text#kotlin.io.path%24appendText(java.nio.file.Path,%20kotlin.CharSequence,%20java.nio.charset.Charset)/charset). Parameters ---------- `text` - text to append to file. `charset` - character set to use for writing text, UTF-8 by default. kotlin createDirectories createDirectories ================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [createDirectories](create-directories) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.createDirectories(     vararg attributes: FileAttribute<*> ): Path ``` Creates a directory ensuring that all nonexistent parent directories exist by creating them first. If the directory already exists, this function does not throw an exception, unlike [Path.createDirectory](create-directory). Parameters ---------- `attributes` - an optional list of file attributes to set atomically when creating the directory. Exceptions ---------- `FileAlreadyExistsException` - if there is already a file located by this path (optional specific exception, some implementations may throw more general [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html)). `IOException` - if an I/O error occurs. `UnsupportedOperationException` - if the [attributes](create-directories#kotlin.io.path%24createDirectories(java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/attributes)array contains an attribute that cannot be set atomically when creating the directory. **See Also** [Files.createDirectories](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createDirectories-java.nio.file.Path-kotlin.Array-) kotlin reader reader ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <reader> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.reader(     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): InputStreamReader ``` Returns a new [InputStreamReader](https://docs.oracle.com/javase/8/docs/api/java/io/InputStreamReader.html) for reading the content of this file. Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. `options` - options to determine how the file is opened. kotlin getAttribute getAttribute ============ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [getAttribute](get-attribute) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.getAttribute(     attribute: String,     vararg options: LinkOption ): Any? ``` Reads the value of a file attribute. The attribute name is specified with the [attribute](get-attribute#kotlin.io.path%24getAttribute(java.nio.file.Path,%20kotlin.String,%20kotlin.Array((java.nio.file.LinkOption)))/attribute) parameter optionally prefixed with the attribute view name: ``` [view_name:]attribute_name ``` When the view name is not specified, it defaults to `basic`. Exceptions ---------- `UnsupportedOperationException` - if the attribute view is not supported. `IllegalArgumentException` - if the attribute name is not specified or is not recognized. **See Also** [Files.getAttribute](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getAttribute-java.nio.file.Path-java.lang.String-kotlin.Array-) kotlin readAttributes readAttributes ============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [readAttributes](read-attributes) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun <reified A : BasicFileAttributes> Path.readAttributes(     vararg options: LinkOption ): A ``` Reads a file's attributes of the specified type [A](read-attributes#A) in bulk. Parameters ---------- `A` - the reified type of the desired attributes, a subtype of [BasicFileAttributes](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/BasicFileAttributes.html). Exceptions ---------- `UnsupportedOperationException` - if the given attributes type [A](read-attributes#A) is not supported. **See Also** [Files.readAttributes](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#readAttributes-java.nio.file.Path-java.lang.Class-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.readAttributes(     attributes: String,     vararg options: LinkOption ): Map<String, Any?> ``` Reads the specified list of attributes of a file in bulk. The list of [attributes](read-attributes#kotlin.io.path%24readAttributes(java.nio.file.Path,%20kotlin.String,%20kotlin.Array((java.nio.file.LinkOption)))/attributes) to read is specified in the following string form: ``` [view:]attribute_name1[,attribute_name2...] ``` So the names are comma-separated and optionally prefixed by the attribute view type name, `basic` by default. The special `*` attribute name can be used to read all attributes of the specified view. Exceptions ---------- `UnsupportedOperationException` - if the attribute view is not supported. `IllegalArgumentException` - if no attributes are specified or an unrecognized attribute is specified. **Return** a Map having an entry for an each attribute read, where the key is the attribute name and the value is the attribute value. **See Also** [Files.readAttributes](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#readAttributes-java.nio.file.Path-java.lang.Class-kotlin.Array-) kotlin setAttribute setAttribute ============ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [setAttribute](set-attribute) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.setAttribute(     attribute: String,     value: Any?,     vararg options: LinkOption ): Path ``` Sets the value of a file attribute. The attribute name is specified with the [attribute](set-attribute#kotlin.io.path%24setAttribute(java.nio.file.Path,%20kotlin.String,%20kotlin.Any?,%20kotlin.Array((java.nio.file.LinkOption)))/attribute) parameter optionally prefixed with the attribute view name: ``` [view_name:]attribute_name ``` When the view name is not specified, it defaults to `basic`. Exceptions ---------- `UnsupportedOperationException` - if the attribute view is not supported. `IllegalArgumentException` - if the attribute name is not specified or is not recognized, or the attribute value is of the correct type but has an inappropriate value. `ClassCastException` - if the attribute value is not of the expected type **See Also** [Files.setAttribute](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#setAttribute-java.nio.file.Path-java.lang.String-java.lang.Object-kotlin.Array-) kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <div> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` operator fun Path.div(other: Path): Path ``` Resolves the given [other](div#kotlin.io.path%24div(java.nio.file.Path,%20java.nio.file.Path)/other) path against this path. This operator is a shortcut for the [Path.resolve](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#resolve-java.nio.file.Path-) function. **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` operator fun Path.div(other: String): Path ``` Resolves the given [other](div#kotlin.io.path%24div(java.nio.file.Path,%20kotlin.String)/other) path string against this path. This operator is a shortcut for the [Path.resolve](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#resolve-java.nio.file.Path-) function. kotlin createSymbolicLinkPointingTo createSymbolicLinkPointingTo ============================ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [createSymbolicLinkPointingTo](create-symbolic-link-pointing-to) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.createSymbolicLinkPointingTo(     target: Path,     vararg attributes: FileAttribute<*> ): Path ``` Creates a new symbolic link located by this path to the given [target](create-symbolic-link-pointing-to#kotlin.io.path%24createSymbolicLinkPointingTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/target). Calling this function may require the process to be started with implementation specific privileges to create symbolic links. Exceptions ---------- `FileAlreadyExistsException` - if a file with this name already exists (optional specific exception, some implementations may throw a more general one). `UnsupportedOperationException` - if the implementation does not support symbolic links or the [attributes](create-symbolic-link-pointing-to#kotlin.io.path%24createSymbolicLinkPointingTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/attributes) array contains an attribute that cannot be set atomically when creating the symbolic link. **See Also** [Files.createSymbolicLink](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createSymbolicLink-java.nio.file.Path-java.nio.file.Path-kotlin.Array-) kotlin forEachDirectoryEntry forEachDirectoryEntry ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [forEachDirectoryEntry](for-each-directory-entry) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` inline fun Path.forEachDirectoryEntry(     glob: String = "*",     action: (Path) -> Unit) ``` Performs the given [action](for-each-directory-entry#kotlin.io.path%24forEachDirectoryEntry(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((java.nio.file.Path,%20kotlin.Unit)))/action) on each entry in this directory optionally filtered by matching against the specified [glob](for-each-directory-entry#kotlin.io.path%24forEachDirectoryEntry(java.nio.file.Path,%20kotlin.String,%20kotlin.Function1((java.nio.file.Path,%20kotlin.Unit)))/glob) pattern. Parameters ---------- `glob` - the globbing pattern. The syntax is specified by the [FileSystem.getPathMatcher](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-) method. Exceptions ---------- `java.util.regex.PatternSyntaxException` - if the glob pattern is invalid. `NotDirectoryException` - If this path does not refer to a directory. `IOException` - If an I/O error occurs. **See Also** [Files.newDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newDirectoryStream-java.nio.file.Path-) kotlin isRegularFile isRegularFile ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isRegularFile](is-regular-file) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isRegularFile(vararg options: LinkOption): Boolean ``` Checks if the file located by this path is a regular file. Parameters ---------- `options` - options to control how symbolic links are handled. **See Also** [Files.isRegularFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isRegularFile-java.nio.file.Path-kotlin.Array-) kotlin fileAttributesView fileAttributesView ================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [fileAttributesView](file-attributes-view) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun <reified V : FileAttributeView> Path.fileAttributesView(     vararg options: LinkOption ): V ``` Returns a file attributes view of a given type [V](file-attributes-view#V) or throws an [UnsupportedOperationException](https://docs.oracle.com/javase/8/docs/api/java/lang/UnsupportedOperationException.html) if the requested attribute view type is not available.. The returned view allows to read and optionally to modify attributes of a file. Parameters ---------- `V` - the reified type of the desired attribute view, a subtype of [FileAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/attribute/FileAttributeView.html). **See Also** [Files.getFileAttributeView](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getFileAttributeView-java.nio.file.Path-java.lang.Class-kotlin.Array-) kotlin relativeToOrSelf relativeToOrSelf ================ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [relativeToOrSelf](relative-to-or-self) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.relativeToOrSelf(base: Path): Path ``` Calculates the relative path for this path from a [base](relative-to-or-self#kotlin.io.path%24relativeToOrSelf(java.nio.file.Path,%20java.nio.file.Path)/base) path. Note that the [base](relative-to-or-self#kotlin.io.path%24relativeToOrSelf(java.nio.file.Path,%20java.nio.file.Path)/base) path is treated as a directory. If this path matches the [base](relative-to-or-self#kotlin.io.path%24relativeToOrSelf(java.nio.file.Path,%20java.nio.file.Path)/base) path, then a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) with an empty path will be returned. **Return** the relative path from [base](relative-to-or-self#kotlin.io.path%24relativeToOrSelf(java.nio.file.Path,%20java.nio.file.Path)/base) to this, or `this` if this and base paths have different roots. kotlin nameWithoutExtension nameWithoutExtension ==================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [nameWithoutExtension](name-without-extension) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` val Path.nameWithoutExtension: String ``` Returns the <name> of this file or directory without an extension, or an empty string if this path has zero path elements. kotlin relativeToOrNull relativeToOrNull ================ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [relativeToOrNull](relative-to-or-null) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.relativeToOrNull(base: Path): Path? ``` Calculates the relative path for this path from a [base](relative-to-or-null#kotlin.io.path%24relativeToOrNull(java.nio.file.Path,%20java.nio.file.Path)/base) path. Note that the [base](relative-to-or-null#kotlin.io.path%24relativeToOrNull(java.nio.file.Path,%20java.nio.file.Path)/base) path is treated as a directory. If this path matches the [base](relative-to-or-null#kotlin.io.path%24relativeToOrNull(java.nio.file.Path,%20java.nio.file.Path)/base) path, then a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) with an empty path will be returned. **Return** the relative path from [base](relative-to-or-null#kotlin.io.path%24relativeToOrNull(java.nio.file.Path,%20java.nio.file.Path)/base) to this, or `null` if this and base paths have different roots. kotlin appendLines appendLines =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [appendLines](append-lines) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.appendLines(     lines: Iterable<CharSequence>,     charset: Charset = Charsets.UTF_8 ): Path ``` Appends the specified collection of char sequences [lines](append-lines#kotlin.io.path%24appendLines(java.nio.file.Path,%20kotlin.collections.Iterable((kotlin.CharSequence)),%20java.nio.charset.Charset)/lines) to a file terminating each one with the platform's line separator. Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default. **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.appendLines(     lines: Sequence<CharSequence>,     charset: Charset = Charsets.UTF_8 ): Path ``` Appends the specified sequence of char sequences [lines](append-lines#kotlin.io.path%24appendLines(java.nio.file.Path,%20kotlin.sequences.Sequence((kotlin.CharSequence)),%20java.nio.charset.Charset)/lines) to a file terminating each one with the platform's line separator. Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default. kotlin appendBytes appendBytes =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [appendBytes](append-bytes) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.appendBytes(array: ByteArray) ``` Appends an [array](append-bytes#kotlin.io.path%24appendBytes(java.nio.file.Path,%20kotlin.ByteArray)/array) of bytes to the content of this file. Parameters ---------- `array` - byte array to append to this file. kotlin writeLines writeLines ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [writeLines](write-lines) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.writeLines(     lines: Iterable<CharSequence>,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): Path ``` Write the specified collection of char sequences [lines](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.collections.Iterable((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/lines) to a file terminating each one with the platform's line separator. By default, the file will be overwritten if it already exists, but you can control this behavior with [options](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.collections.Iterable((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/options). Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default. **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.writeLines(     lines: Sequence<CharSequence>,     charset: Charset = Charsets.UTF_8,     vararg options: OpenOption ): Path ``` Write the specified sequence of char sequences [lines](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.sequences.Sequence((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/lines) to a file terminating each one with the platform's line separator. By default, the file will be overwritten if it already exists, but you can control this behavior with [options](write-lines#kotlin.io.path%24writeLines(java.nio.file.Path,%20kotlin.sequences.Sequence((kotlin.CharSequence)),%20java.nio.charset.Charset,%20kotlin.Array((java.nio.file.OpenOption)))/options). Parameters ---------- `charset` - character set to use for writing text, UTF-8 by default.
programming_docs
kotlin writeBytes writeBytes ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [writeBytes](write-bytes) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.writeBytes(     array: ByteArray,     vararg options: OpenOption) ``` Writes an [array](write-bytes#kotlin.io.path%24writeBytes(java.nio.file.Path,%20kotlin.ByteArray,%20kotlin.Array((java.nio.file.OpenOption)))/array) of bytes to this file. By default, the file will be overwritten if it already exists, but you can control this behavior with [options](write-bytes#kotlin.io.path%24writeBytes(java.nio.file.Path,%20kotlin.ByteArray,%20kotlin.Array((java.nio.file.OpenOption)))/options). Parameters ---------- `array` - byte array to write into this file. `options` - options to determine how the file is opened. kotlin visitFileTree visitFileTree ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [visitFileTree](visit-file-tree) **Platform and version requirements:** JVM (1.7), JRE7 (1.7) ``` @ExperimentalPathApi fun Path.visitFileTree(     visitor: FileVisitor<Path>,     maxDepth: Int = Int.MAX_VALUE,     followLinks: Boolean = false) ``` Visits this directory and all its content with the specified [visitor](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20java.nio.file.FileVisitor((java.nio.file.Path)),%20kotlin.Int,%20kotlin.Boolean)/visitor). The traversal is in depth-first order and starts at this directory. The specified [visitor](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20java.nio.file.FileVisitor((java.nio.file.Path)),%20kotlin.Int,%20kotlin.Boolean)/visitor) is invoked on each file encountered. Parameters ---------- `visitor` - the [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) that receives callbacks. `maxDepth` - the maximum depth to traverse. By default, there is no limit. `followLinks` - specifies whether to follow symbolic links, `false` by default. **See Also** [Files.walkFileTree](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#walkFileTree-java.nio.file.Path-java.util.Set-int-java.nio.file.FileVisitor-) **Platform and version requirements:** JVM (1.7), JRE7 (1.7) ``` @ExperimentalPathApi fun Path.visitFileTree(     maxDepth: Int = Int.MAX_VALUE,     followLinks: Boolean = false,     builderAction: FileVisitorBuilder.() -> Unit) ``` Visits this directory and all its content with the [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) defined in [builderAction](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction). This function works the same as [Path.visitFileTree](visit-file-tree). It is introduced to streamline the cases when a [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html) is created only to be immediately used for a file tree traversal. The trailing lambda [builderAction](visit-file-tree#kotlin.io.path%24visitFileTree(java.nio.file.Path,%20kotlin.Int,%20kotlin.Boolean,%20kotlin.Function1((kotlin.io.path.FileVisitorBuilder,%20kotlin.Unit)))/builderAction) is passed to [fileVisitor](../file-visitor) to get the file visitor. Example: ``` projectDirectory.visitFileTree { onPreVisitDirectory { directory, _ -> if (directory.name == "build") { directory.toFile().deleteRecursively() FileVisitResult.SKIP_SUBTREE } else { FileVisitResult.CONTINUE } } onVisitFile { file, _ -> if (file.extension == "class") { file.deleteExisting() } FileVisitResult.CONTINUE } } ``` Parameters ---------- `maxDepth` - the maximum depth to traverse. By default, there is no limit. `followLinks` - specifies whether to follow symbolic links, `false` by default. `builderAction` - the function that defines [FileVisitor](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html). **See Also** [Path.visitFileTree](visit-file-tree) [fileVisitor](../file-visitor) kotlin isHidden isHidden ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isHidden](is-hidden) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isHidden(): Boolean ``` Checks if the file located by this path is considered hidden. This check is dependant on the current filesystem. For example, on UNIX-like operating systems, a path is considered hidden if its name begins with a dot. On Windows, file attributes are checked. **See Also** [Files.isHidden](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isHidden-java.nio.file.Path-) kotlin outputStream outputStream ============ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [outputStream](output-stream) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.outputStream(     vararg options: OpenOption ): OutputStream ``` Constructs a new OutputStream of this file and returns it as a result. The [options](output-stream#kotlin.io.path%24outputStream(java.nio.file.Path,%20kotlin.Array((java.nio.file.OpenOption)))/options) parameter determines how the file is opened. If no options are present then it is equivalent to opening the file with the [CREATE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#CREATE), [TRUNCATE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#TRUNCATE_EXISTING), and [WRITE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#WRITE) options. kotlin createDirectory createDirectory =============== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [createDirectory](create-directory) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.createDirectory(     vararg attributes: FileAttribute<*> ): Path ``` Creates a new directory or throws an exception if there is already a file or directory located by this path. Note that the parent directory where this directory is going to be created must already exist. If you need to create all non-existent parent directories, use [Path.createDirectories](create-directories). Parameters ---------- `attributes` - an optional list of file attributes to set atomically when creating the directory. Exceptions ---------- `FileAlreadyExistsException` - if there is already a file or directory located by this path (optional specific exception, some implementations may throw more general [IOException](https://docs.oracle.com/javase/8/docs/api/java/io/IOException.html)). `IOException` - if an I/O error occurs or the parent directory does not exist. `UnsupportedOperationException` - if the [attributes](create-directory#kotlin.io.path%24createDirectory(java.nio.file.Path,%20kotlin.Array((java.nio.file.attribute.FileAttribute((kotlin.Any)))))/attributes)array contains an attribute that cannot be set atomically when creating the directory. **See Also** [Files.createDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createDirectory-java.nio.file.Path-kotlin.Array-) kotlin isSameFileAs isSameFileAs ============ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isSameFileAs](is-same-file-as) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isSameFileAs(other: Path): Boolean ``` Checks if the file located by this path points to the same file or directory as [other](is-same-file-as#kotlin.io.path%24isSameFileAs(java.nio.file.Path,%20java.nio.file.Path)/other). **See Also** [Files.isSameFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isSameFile-java.nio.file.Path-java.nio.file.Path-) kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <name> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` val Path.name: String ``` Returns the name of the file or directory denoted by this path as a string, or an empty string if this path has zero path elements. kotlin copyTo copyTo ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [copyTo](copy-to) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.copyTo(     target: Path,     overwrite: Boolean = false ): Path ``` Copies a file or directory located by this path to the given [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path. Unlike `File.copyTo`, if some directories on the way to the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) are missing, then they won't be created automatically. You can use the following approach to ensure that required intermediate directories are created: ``` sourcePath.copyTo(destinationPath.apply { parent?.createDirectories() }) ``` If the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path already exists, this function will fail unless [overwrite](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/overwrite) argument is set to `true`. When [overwrite](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/overwrite) is `true` and [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) is a directory, it is replaced only if it is empty. If this path is a directory, it is copied without its content, i.e. an empty [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) directory is created. If you want to copy directory including its contents, use [copyToRecursively](copy-to-recursively). The operation doesn't preserve copied file attributes such as creation/modification date, permissions, etc. Parameters ---------- `overwrite` - `true` if destination overwrite is allowed. Exceptions ---------- `NoSuchFileException` - if the source path doesn't exist. `FileAlreadyExistsException` - if the destination path already exists and [overwrite](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/overwrite) argument is set to `false`. `DirectoryNotEmptyException` - if the destination path point to an existing directory and [overwrite](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/overwrite) argument is `true`, when the directory being replaced is not empty. `IOException` - if any errors occur while copying. **Return** the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path. **See Also** [Files.copy](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.nio.file.Path-java.nio.file.Path-kotlin.Array-) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.copyTo(     target: Path,     vararg options: CopyOption ): Path ``` Copies a file or directory located by this path to the given [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) path. Unlike `File.copyTo`, if some directories on the way to the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) are missing, then they won't be created automatically. You can use the following approach to ensure that required intermediate directories are created: ``` sourcePath.copyTo(destinationPath.apply { parent?.createDirectories() }) ``` If the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) path already exists, this function will fail unless the [REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) is option is used. When [REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) is used and [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) is a directory, it is replaced only if it is empty. If this path is a directory, it is copied *without* its content, i.e. an empty [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) directory is created. If you want to copy a directory including its contents, use [copyToRecursively](copy-to-recursively). The operation doesn't preserve copied file attributes such as creation/modification date, permissions, etc. unless [COPY\_ATTRIBUTES](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#COPY_ATTRIBUTES) is used. Parameters ---------- `options` - options to control how the path is copied. Exceptions ---------- `NoSuchFileException` - if the source path doesn't exist. `FileAlreadyExistsException` - if the destination path already exists and [REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) is not used. `DirectoryNotEmptyException` - if the destination path point to an existing directory and [REPLACE\_EXISTING](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardCopyOption.html#REPLACE_EXISTING) is used, when the directory being replaced is not empty. `IOException` - if any errors occur while copying. **Return** the [target](copy-to#kotlin.io.path%24copyTo(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Array((java.nio.file.CopyOption)))/target) path. **See Also** [Files.copy](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#copy-java.nio.file.Path-java.nio.file.Path-kotlin.Array-) kotlin isReadable isReadable ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isReadable](is-readable) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isReadable(): Boolean ``` Checks if the file located by this path exists and is readable. **See Also** [Files.isReadable](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isReadable-java.nio.file.Path-) kotlin useLines useLines ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [useLines](use-lines) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` inline fun <T> Path.useLines(     charset: Charset = Charsets.UTF_8,     block: (Sequence<String>) -> T ): T ``` Calls the [block](use-lines#kotlin.io.path%24useLines(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.sequences.Sequence((kotlin.String)),%20kotlin.io.path.useLines.T)))/block) callback giving it a sequence of all the lines in this file and closes the reader once the processing is complete. Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. **Return** the value returned by [block](use-lines#kotlin.io.path%24useLines(java.nio.file.Path,%20java.nio.charset.Charset,%20kotlin.Function1((kotlin.sequences.Sequence((kotlin.String)),%20kotlin.io.path.useLines.T)))/block). kotlin isExecutable isExecutable ============ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [isExecutable](is-executable) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.isExecutable(): Boolean ``` Checks if the file located by this path exists and is executable. **See Also** [Files.isExecutable](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isExecutable-java.nio.file.Path-) kotlin readText readText ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [readText](read-text) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.readText(charset: Charset = Charsets.UTF_8): String ``` Gets the entire content of this file as a String using UTF-8 or the specified [charset](read-text#kotlin.io.path%24readText(java.nio.file.Path,%20java.nio.charset.Charset)/charset). It's not recommended to use this function on huge files. For reading large files or files of unknown size, open a [Reader](reader) and read blocks of text sequentially. Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. **Return** the entire content of this file as a String. kotlin invariantSeparatorsPathString invariantSeparatorsPathString ============================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [invariantSeparatorsPathString](invariant-separators-path-string) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` val Path.invariantSeparatorsPathString: String ``` Returns the string representation of this path using the invariant separator '/' to separate names in the path. kotlin readSymbolicLink readSymbolicLink ================ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [readSymbolicLink](read-symbolic-link) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.readSymbolicLink(): Path ``` Reads the target of a symbolic link located by this path. Exceptions ---------- `UnsupportedOperationException` - if symbolic links are not supported by this implementation. `NotLinkException` - if the target is not a symbolic link (optional specific exception, some implementations may throw a more general one). **See Also** [Files.readSymbolicLink](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#readSymbolicLink-java.nio.file.Path-) kotlin getLastModifiedTime getLastModifiedTime =================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [getLastModifiedTime](get-last-modified-time) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.getLastModifiedTime(     vararg options: LinkOption ): FileTime ``` Returns the last modified time of the file located by this path. If the file system does not support modification timestamps, some implementation-specific default is returned. **See Also** [Files.getLastModifiedTime](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getLastModifiedTime-java.nio.file.Path-kotlin.Array-) kotlin fileStore fileStore ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [fileStore](file-store) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.fileStore(): FileStore ``` Returns the [FileStore](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileStore.html) representing the file store where a file is located. **See Also** [Files.getFileStore](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#getFileStore-java.nio.file.Path-) kotlin readLines readLines ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [readLines](read-lines) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.readLines(     charset: Charset = Charsets.UTF_8 ): List<String> ``` Reads the file content as a list of lines. It's not recommended to use this function on huge files. For reading lines of a large file or a file of unknown size, use [Path.forEachLine](for-each-line) or [Path.useLines](use-lines). Parameters ---------- `charset` - character set to use for reading text, UTF-8 by default. **Return** list of file lines.
programming_docs
kotlin absolutePathString absolutePathString ================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [absolutePathString](absolute-path-string) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.absolutePathString(): String ``` Converts this possibly relative path to an absolute path and returns its string representation. Basically, this method is a combination of calling <absolute> and [pathString](path-string). May throw an exception if the file system is inaccessible or getting the default directory path is prohibited. See [Path.toAbsolutePath](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toAbsolutePath--) for further details about the function contract and possible exceptions. kotlin readBytes readBytes ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [readBytes](read-bytes) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.readBytes(): ByteArray ``` Gets the entire content of this file as a byte array. It's not recommended to use this function on huge files. It has an internal limitation of approximately 2 GB byte array size. For reading large files or files of unknown size, open an [InputStream](input-stream) and read blocks sequentially. **Return** the entire content of this file as a byte array. kotlin absolute absolute ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <absolute> **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.absolute(): Path ``` Converts this possibly relative path to an absolute path. If this path is already [absolute](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#isAbsolute--), returns this path unchanged. Otherwise, resolves this path, usually against the default directory of the file system. May throw an exception if the file system is inaccessible or getting the default directory path is prohibited. See [Path.toAbsolutePath](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html#toAbsolutePath--) for further details about the function contract and possible exceptions. kotlin walk walk ==== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / <walk> **Platform and version requirements:** JVM (1.7), JRE7 (1.7) ``` @ExperimentalPathApi fun Path.walk(     vararg options: PathWalkOption ): Sequence<Path> ``` Returns a sequence of paths for visiting this directory and all its content. By default, only files are visited, in depth-first order, and symbolic links are not followed. The combination of [options](walk#kotlin.io.path%24walk(java.nio.file.Path,%20kotlin.Array((kotlin.io.path.PathWalkOption)))/options) overrides the default behavior. See [PathWalkOption](../-path-walk-option/index). The order in which sibling files are visited is unspecified. If after calling this function new files get added or deleted from the file tree rooted at this directory, the changes may or may not appear in the returned sequence. If the file located by this path does not exist, an empty sequence is returned. if the file located by this path is not a directory, a sequence containing only this path is returned. kotlin fileSize fileSize ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [fileSize](file-size) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.fileSize(): Long ``` Returns the size of a regular file as a Long value of bytes or throws an exception if the file doesn't exist. Exceptions ---------- `IOException` - if an I/O error occurred. **See Also** [Files.size](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#size-java.nio.file.Path-) kotlin createLinkPointingTo createLinkPointingTo ==================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [createLinkPointingTo](create-link-pointing-to) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.createLinkPointingTo(target: Path): Path ``` Creates a new link (directory entry) located by this path for the existing file [target](create-link-pointing-to#kotlin.io.path%24createLinkPointingTo(java.nio.file.Path,%20java.nio.file.Path)/target). Calling this function may require the process to be started with implementation specific privileges to create hard links or to create links to directories. Exceptions ---------- `FileAlreadyExistsException` - if a file with this name already exists (optional specific exception, some implementations may throw a more general one). `UnsupportedOperationException` - if the implementation does not support creating a hard link. **See Also** [Files.createLink](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#createLink-java.nio.file.Path-java.nio.file.Path-) kotlin inputStream inputStream =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [inputStream](input-stream) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.inputStream(vararg options: OpenOption): InputStream ``` Constructs a new InputStream of this file and returns it as a result. The [options](input-stream#kotlin.io.path%24inputStream(java.nio.file.Path,%20kotlin.Array((java.nio.file.OpenOption)))/options) parameter determines how the file is opened. If no options are present then it is equivalent to opening the file with the [READ](https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#READ) option. kotlin invariantSeparatorsPath invariantSeparatorsPath ======================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [invariantSeparatorsPath](invariant-separators-path) **Platform and version requirements:** JVM (1.4), JRE7 (1.4) ``` @ExperimentalPathApi inline val Path.invariantSeparatorsPath: String ``` **Deprecated:** Use invariantSeparatorsPathString property instead. kotlin setLastModifiedTime setLastModifiedTime =================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [setLastModifiedTime](set-last-modified-time) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.setLastModifiedTime(value: FileTime): Path ``` Sets the last modified time attribute for the file located by this path. If the file system does not support modification timestamps, the behavior of this method is not defined. **See Also** [Files.setLastModifiedTime](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#setLastModifiedTime-java.nio.file.Path-java.nio.file.attribute.FileTime-) kotlin pathString pathString ========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [pathString](path-string) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` inline val Path.pathString: String ``` Returns the string representation of this path. The returned path string uses the default name [separator](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getSeparator--) to separate names in the path. This property is a synonym to Path.toString function. kotlin listDirectoryEntries listDirectoryEntries ==================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.nio.file.Path](index) / [listDirectoryEntries](list-directory-entries) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun Path.listDirectoryEntries(glob: String = "*"): List<Path> ``` Returns a list of the entries in this directory optionally filtered by matching against the specified [glob](list-directory-entries#kotlin.io.path%24listDirectoryEntries(java.nio.file.Path,%20kotlin.String)/glob) pattern. Parameters ---------- `glob` - the globbing pattern. The syntax is specified by the [FileSystem.getPathMatcher](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileSystem.html#getPathMatcher-java.lang.String-) method. Exceptions ---------- `java.util.regex.PatternSyntaxException` - if the glob pattern is invalid. `NotDirectoryException` - If this path does not refer to a directory. `IOException` - If an I/O error occurs. **See Also** [Files.newDirectoryStream](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#newDirectoryStream-java.nio.file.Path-) kotlin SKIP_SUBTREE SKIP\_SUBTREE ============= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionResult](index) / [SKIP\_SUBTREE](-s-k-i-p_-s-u-b-t-r-e-e) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` SKIP_SUBTREE ``` Skip the directory content, continue with the next entry outside the directory in the traversal order. For files this option is equivalent to [CONTINUE](-c-o-n-t-i-n-u-e). kotlin CONTINUE CONTINUE ======== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionResult](index) / [CONTINUE](-c-o-n-t-i-n-u-e) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` CONTINUE ``` Continue with the next entry in the traversal order. kotlin CopyActionResult CopyActionResult ================ [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionResult](index) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` @ExperimentalPathApi enum class CopyActionResult ``` The result of the `copyAction` function passed to [Path.copyToRecursively](../java.nio.file.-path/copy-to-recursively) that specifies further actions when copying an entry. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [CONTINUE](-c-o-n-t-i-n-u-e) Continue with the next entry in the traversal order. **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [SKIP\_SUBTREE](-s-k-i-p_-s-u-b-t-r-e-e) Skip the directory content, continue with the next entry outside the directory in the traversal order. For files this option is equivalent to [CONTINUE](-c-o-n-t-i-n-u-e). **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [TERMINATE](-t-e-r-m-i-n-a-t-e) Stop the recursive copy function. The function will return without throwing exception. kotlin TERMINATE TERMINATE ========= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionResult](index) / [TERMINATE](-t-e-r-m-i-n-a-t-e) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` TERMINATE ``` Stop the recursive copy function. The function will return without throwing exception. kotlin copyToIgnoringExistingDirectory copyToIgnoringExistingDirectory =============================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionContext](index) / [copyToIgnoringExistingDirectory](copy-to-ignoring-existing-directory) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` abstract fun Path.copyToIgnoringExistingDirectory(     target: Path,     followLinks: Boolean ): CopyActionResult ``` Copies the entry located by this path to the specified [target](copy-to-ignoring-existing-directory#kotlin.io.path.CopyActionContext%24copyToIgnoringExistingDirectory(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path, except if both this and [target](copy-to-ignoring-existing-directory#kotlin.io.path.CopyActionContext%24copyToIgnoringExistingDirectory(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) entries are directories, in which case the method completes without copying the entry. The entry is copied using `this.copyTo(target, *followLinksOption)`. See [kotlin.io.path.copyTo](../java.nio.file.-path/copy-to). Parameters ---------- `target` - the path to copy this entry to. `followLinks` - `false` to copy the entry itself even if it's a symbolic link. `true` to copy its target if this entry is a symbolic link. If this entry is not a symbolic link, the value of this parameter doesn't make any difference. **Return** [CopyActionResult.CONTINUE](../-copy-action-result/-c-o-n-t-i-n-u-e) kotlin CopyActionContext CopyActionContext ================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [CopyActionContext](index) **Platform and version requirements:** JVM (1.8), JRE7 (1.8) ``` @ExperimentalPathApi interface CopyActionContext ``` Context for the `copyAction` function passed to [Path.copyToRecursively](../java.nio.file.-path/copy-to-recursively). Functions --------- **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [copyToIgnoringExistingDirectory](copy-to-ignoring-existing-directory) Copies the entry located by this path to the specified [target](copy-to-ignoring-existing-directory#kotlin.io.path.CopyActionContext%24copyToIgnoringExistingDirectory(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) path, except if both this and [target](copy-to-ignoring-existing-directory#kotlin.io.path.CopyActionContext%24copyToIgnoringExistingDirectory(java.nio.file.Path,%20java.nio.file.Path,%20kotlin.Boolean)/target) entries are directories, in which case the method completes without copying the entry. ``` abstract fun Path.copyToIgnoringExistingDirectory(     target: Path,     followLinks: Boolean ): CopyActionResult ``` kotlin FileVisitorBuilder FileVisitorBuilder ================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [FileVisitorBuilder](index) **Platform and version requirements:** JVM (1.7), JRE7 (1.7) ``` @ExperimentalPathApi sealed interface FileVisitorBuilder ``` The builder to provide implementation of the file visitor that [fileVisitor](../file-visitor) builds. Functions --------- **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [onPostVisitDirectory](on-post-visit-directory) Overrides the corresponding function of the built file visitor with the provided [function](on-post-visit-directory#kotlin.io.path.FileVisitorBuilder%24onPostVisitDirectory(kotlin.Function2((java.nio.file.Path,%20java.io.IOException?,%20java.nio.file.FileVisitResult)))/function). ``` abstract fun onPostVisitDirectory(     function: (directory: Path, exception: IOException?) -> FileVisitResult) ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [onPreVisitDirectory](on-pre-visit-directory) Overrides the corresponding function of the built file visitor with the provided [function](on-pre-visit-directory#kotlin.io.path.FileVisitorBuilder%24onPreVisitDirectory(kotlin.Function2((java.nio.file.Path,%20java.nio.file.attribute.BasicFileAttributes,%20java.nio.file.FileVisitResult)))/function). ``` abstract fun onPreVisitDirectory(     function: (directory: Path, attributes: BasicFileAttributes) -> FileVisitResult) ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [onVisitFile](on-visit-file) Overrides the corresponding function of the built file visitor with the provided [function](on-visit-file#kotlin.io.path.FileVisitorBuilder%24onVisitFile(kotlin.Function2((java.nio.file.Path,%20java.nio.file.attribute.BasicFileAttributes,%20java.nio.file.FileVisitResult)))/function). ``` abstract fun onVisitFile(     function: (file: Path, attributes: BasicFileAttributes) -> FileVisitResult) ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [onVisitFileFailed](on-visit-file-failed) Overrides the corresponding function of the built file visitor with the provided [function](on-visit-file-failed#kotlin.io.path.FileVisitorBuilder%24onVisitFileFailed(kotlin.Function2((java.nio.file.Path,%20java.io.IOException,%20java.nio.file.FileVisitResult)))/function). ``` abstract fun onVisitFileFailed(     function: (file: Path, exception: IOException) -> FileVisitResult) ``` kotlin onVisitFile onVisitFile =========== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [FileVisitorBuilder](index) / [onVisitFile](on-visit-file) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` abstract fun onVisitFile(     function: (file: Path, attributes: BasicFileAttributes) -> FileVisitResult) ``` Overrides the corresponding function of the built file visitor with the provided [function](on-visit-file#kotlin.io.path.FileVisitorBuilder%24onVisitFile(kotlin.Function2((java.nio.file.Path,%20java.nio.file.attribute.BasicFileAttributes,%20java.nio.file.FileVisitResult)))/function). By default, [FileVisitor.visitFile](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#visitFile-java.nio.file.FileVisitor.T-java.nio.file.attribute.BasicFileAttributes-) of the built file visitor returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE). kotlin onPostVisitDirectory onPostVisitDirectory ==================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [FileVisitorBuilder](index) / [onPostVisitDirectory](on-post-visit-directory) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` abstract fun onPostVisitDirectory(     function: (directory: Path, exception: IOException?) -> FileVisitResult) ``` Overrides the corresponding function of the built file visitor with the provided [function](on-post-visit-directory#kotlin.io.path.FileVisitorBuilder%24onPostVisitDirectory(kotlin.Function2((java.nio.file.Path,%20java.io.IOException?,%20java.nio.file.FileVisitResult)))/function). By default, if the directory iteration completes without an I/O exception, [FileVisitor.postVisitDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#postVisitDirectory-java.nio.file.FileVisitor.T-java.io.IOException-) of the built file visitor returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE); otherwise it re-throws the I/O exception that caused the iteration of the directory to terminate prematurely. kotlin onPreVisitDirectory onPreVisitDirectory =================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [FileVisitorBuilder](index) / [onPreVisitDirectory](on-pre-visit-directory) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` abstract fun onPreVisitDirectory(     function: (directory: Path, attributes: BasicFileAttributes) -> FileVisitResult) ``` Overrides the corresponding function of the built file visitor with the provided [function](on-pre-visit-directory#kotlin.io.path.FileVisitorBuilder%24onPreVisitDirectory(kotlin.Function2((java.nio.file.Path,%20java.nio.file.attribute.BasicFileAttributes,%20java.nio.file.FileVisitResult)))/function). By default, [FileVisitor.preVisitDirectory](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#preVisitDirectory-java.nio.file.FileVisitor.T-java.nio.file.attribute.BasicFileAttributes-) of the built file visitor returns [FileVisitResult.CONTINUE](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitResult.html#CONTINUE). kotlin onVisitFileFailed onVisitFileFailed ================= [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [FileVisitorBuilder](index) / [onVisitFileFailed](on-visit-file-failed) **Platform and version requirements:** JVM (1.0), JRE7 (1.0) ``` abstract fun onVisitFileFailed(     function: (file: Path, exception: IOException) -> FileVisitResult) ``` Overrides the corresponding function of the built file visitor with the provided [function](on-visit-file-failed#kotlin.io.path.FileVisitorBuilder%24onVisitFileFailed(kotlin.Function2((java.nio.file.Path,%20java.io.IOException,%20java.nio.file.FileVisitResult)))/function). By default, [FileVisitor.visitFileFailed](https://docs.oracle.com/javase/8/docs/api/java/nio/file/FileVisitor.html#visitFileFailed-java.nio.file.FileVisitor.T-java.io.IOException-) of the built file visitor re-throws the I/O exception that prevented the file from being visited.
programming_docs
kotlin Extensions for java.net.URI Extensions for java.net.URI =========================== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.net.URI](index) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) #### [toPath](to-path) Converts this URI to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object. ``` fun URI.toPath(): Path ``` kotlin toPath toPath ====== [kotlin-stdlib](../../../../../../index) / [kotlin.io.path](../index) / [java.net.URI](index) / [toPath](to-path) **Platform and version requirements:** JVM (1.5), JRE7 (1.5) ``` fun URI.toPath(): Path ``` Converts this URI to a [Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) object. **See Also** [Paths.get](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Paths.html#get-java.lang.String-kotlin.Array-) kotlin compareBy compareBy ========= [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [compareBy](compare-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> compareBy(     vararg selectors: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator using the sequence of functions to calculate a result of comparison. The functions are called sequentially, receive the given values `a` and `b` and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. As soon as the [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances returned by a function for `a` and `b` values do not compare as equal, the result of that comparison is returned from the [Comparator](../kotlin/-comparator/index#kotlin.Comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val sorted = list.sortedWith(compareBy( { it.length }, { it } )) println(sorted) // [a, b, aa, bb] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> compareBy(     crossinline selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator using the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val sorted = list.sortedWith(compareBy { it.length }) println(sorted) // [b, a, aa, bb] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> compareBy(     comparator: Comparator<in K>,     crossinline selector: (T) -> K ): Comparator<T> ``` Creates a comparator using the [selector](compare-by#kotlin.comparisons%24compareBy(kotlin.Comparator((kotlin.comparisons.compareBy.K)),%20kotlin.Function1((kotlin.comparisons.compareBy.T,%20kotlin.comparisons.compareBy.K)))/selector) function to transform values being compared and then applying the specified [comparator](compare-by#kotlin.comparisons%24compareBy(kotlin.Comparator((kotlin.comparisons.compareBy.K)),%20kotlin.Function1((kotlin.comparisons.compareBy.T,%20kotlin.comparisons.compareBy.K)))/comparator) to compare transformed values. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('B', 'a', 'A', 'b') val sorted = list.sortedWith( compareBy(String.CASE_INSENSITIVE_ORDER) { v -> v.toString() } ) println(sorted) // [a, A, B, b] //sampleEnd } ``` kotlin Package kotlin.comparisons Package kotlin.comparisons ========================== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) Helper functions for creating Comparator instances. Helper functions for creating [Comparator](https://docs.oracle.com/javase/8/docs/api/java/util/Comparator.html) instances. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareBy](compare-by) Creates a comparator using the sequence of functions to calculate a result of comparison. The functions are called sequentially, receive the given values `a` and `b` and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. As soon as the [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances returned by a function for `a` and `b` values do not compare as equal, the result of that comparison is returned from the [Comparator](../kotlin/-comparator/index#kotlin.Comparator). ``` fun <T> compareBy(     vararg selectors: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator using the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> compareBy(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator using the [selector](compare-by#kotlin.comparisons%24compareBy(kotlin.Comparator((kotlin.comparisons.compareBy.K)),%20kotlin.Function1((kotlin.comparisons.compareBy.T,%20kotlin.comparisons.compareBy.K)))/selector) function to transform values being compared and then applying the specified [comparator](compare-by#kotlin.comparisons%24compareBy(kotlin.Comparator((kotlin.comparisons.compareBy.K)),%20kotlin.Function1((kotlin.comparisons.compareBy.T,%20kotlin.comparisons.compareBy.K)))/comparator) to compare transformed values. ``` fun <T, K> compareBy(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareByDescending](compare-by-descending) Creates a descending comparator using the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> compareByDescending(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a descending comparator using the [selector](compare-by-descending#kotlin.comparisons%24compareByDescending(kotlin.Comparator((kotlin.comparisons.compareByDescending.K)),%20kotlin.Function1((kotlin.comparisons.compareByDescending.T,%20kotlin.comparisons.compareByDescending.K)))/selector) function to transform values being compared and then applying the specified [comparator](compare-by-descending#kotlin.comparisons%24compareByDescending(kotlin.Comparator((kotlin.comparisons.compareByDescending.K)),%20kotlin.Function1((kotlin.comparisons.compareByDescending.T,%20kotlin.comparisons.compareByDescending.K)))/comparator) to compare transformed values. ``` fun <T, K> compareByDescending(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareValues](compare-values) Compares two nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values. Null is considered less than any value. ``` fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareValuesBy](compare-values-by) Compares two values using the specified functions [selectors](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/selectors) to calculate the result of the comparison. The functions are called sequentially, receive the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/b) and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. As soon as the [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances returned by a function for [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/b) values do not compare as equal, the result of that comparison is returned. ``` fun <T> compareValuesBy(     a: T,     b: T,     vararg selectors: (T) -> Comparable<*>? ): Int ``` Compares two values using the specified [selector](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/selector) function to calculate the result of the comparison. The function is applied to the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/b) and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. The result of comparison of these [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances is returned. ``` fun <T> compareValuesBy(     a: T,     b: T,     selector: (T) -> Comparable<*>? ): Int ``` Compares two values using the specified [selector](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/selector) function to calculate the result of the comparison. The function is applied to the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/b) and return objects of type K which are then being compared with the given [comparator](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/comparator). ``` fun <T, K> compareValuesBy(     a: T,     b: T,     comparator: Comparator<in K>,     selector: (T) -> K ): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [maxOf](max-of) Returns the greater of three values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). ``` fun <T> maxOf(     a: T,     b: T,     c: T,     comparator: Comparator<in T> ): T ``` Returns the greater of two values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). ``` fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T ``` Returns the greater of the given values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.Array((kotlin.comparisons.maxOf.T)),%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). ``` fun <T> maxOf(     a: T,     vararg other: T,     comparator: Comparator<in T> ): T ``` Returns the greater of two values. ``` fun maxOf(a: UInt, b: UInt): UInt ``` ``` fun maxOf(a: ULong, b: ULong): ULong ``` ``` fun maxOf(a: UByte, b: UByte): UByte ``` ``` fun maxOf(a: UShort, b: UShort): UShort ``` ``` fun <T : Comparable<T>> maxOf(a: T, b: T): T ``` ``` fun maxOf(a: Byte, b: Byte): Byte ``` ``` fun maxOf(a: Short, b: Short): Short ``` ``` fun maxOf(a: Int, b: Int): Int ``` ``` fun maxOf(a: Long, b: Long): Long ``` ``` fun maxOf(a: Float, b: Float): Float ``` ``` fun maxOf(a: Double, b: Double): Double ``` Returns the greater of three values. ``` fun maxOf(a: UInt, b: UInt, c: UInt): UInt ``` ``` fun maxOf(a: ULong, b: ULong, c: ULong): ULong ``` ``` fun maxOf(a: UByte, b: UByte, c: UByte): UByte ``` ``` fun maxOf(a: UShort, b: UShort, c: UShort): UShort ``` ``` fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T ``` ``` fun maxOf(a: Byte, b: Byte, c: Byte): Byte ``` ``` fun maxOf(a: Short, b: Short, c: Short): Short ``` ``` fun maxOf(a: Int, b: Int, c: Int): Int ``` ``` fun maxOf(a: Long, b: Long, c: Long): Long ``` ``` fun maxOf(a: Float, b: Float, c: Float): Float ``` ``` fun maxOf(a: Double, b: Double, c: Double): Double ``` Returns the greater of the given values. ``` fun maxOf(a: UInt, vararg other: UInt): UInt ``` ``` fun maxOf(a: ULong, vararg other: ULong): ULong ``` ``` fun maxOf(a: UByte, vararg other: UByte): UByte ``` ``` fun maxOf(a: UShort, vararg other: UShort): UShort ``` ``` fun <T : Comparable<T>> maxOf(a: T, vararg other: T): T ``` ``` fun maxOf(a: Byte, vararg other: Byte): Byte ``` ``` fun maxOf(a: Short, vararg other: Short): Short ``` ``` fun maxOf(a: Int, vararg other: Int): Int ``` ``` fun maxOf(a: Long, vararg other: Long): Long ``` ``` fun maxOf(a: Float, vararg other: Float): Float ``` ``` fun maxOf(a: Double, vararg other: Double): Double ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [minOf](min-of) Returns the smaller of three values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). ``` fun <T> minOf(     a: T,     b: T,     c: T,     comparator: Comparator<in T> ): T ``` Returns the smaller of two values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). ``` fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T ``` Returns the smaller of the given values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.Array((kotlin.comparisons.minOf.T)),%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). ``` fun <T> minOf(     a: T,     vararg other: T,     comparator: Comparator<in T> ): T ``` Returns the smaller of two values. ``` fun minOf(a: UInt, b: UInt): UInt ``` ``` fun minOf(a: ULong, b: ULong): ULong ``` ``` fun minOf(a: UByte, b: UByte): UByte ``` ``` fun minOf(a: UShort, b: UShort): UShort ``` ``` fun <T : Comparable<T>> minOf(a: T, b: T): T ``` ``` fun minOf(a: Byte, b: Byte): Byte ``` ``` fun minOf(a: Short, b: Short): Short ``` ``` fun minOf(a: Int, b: Int): Int ``` ``` fun minOf(a: Long, b: Long): Long ``` ``` fun minOf(a: Float, b: Float): Float ``` ``` fun minOf(a: Double, b: Double): Double ``` Returns the smaller of three values. ``` fun minOf(a: UInt, b: UInt, c: UInt): UInt ``` ``` fun minOf(a: ULong, b: ULong, c: ULong): ULong ``` ``` fun minOf(a: UByte, b: UByte, c: UByte): UByte ``` ``` fun minOf(a: UShort, b: UShort, c: UShort): UShort ``` ``` fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T ``` ``` fun minOf(a: Byte, b: Byte, c: Byte): Byte ``` ``` fun minOf(a: Short, b: Short, c: Short): Short ``` ``` fun minOf(a: Int, b: Int, c: Int): Int ``` ``` fun minOf(a: Long, b: Long, c: Long): Long ``` ``` fun minOf(a: Float, b: Float, c: Float): Float ``` ``` fun minOf(a: Double, b: Double, c: Double): Double ``` Returns the smaller of the given values. ``` fun minOf(a: UInt, vararg other: UInt): UInt ``` ``` fun minOf(a: ULong, vararg other: ULong): ULong ``` ``` fun minOf(a: UByte, vararg other: UByte): UByte ``` ``` fun minOf(a: UShort, vararg other: UShort): UShort ``` ``` fun <T : Comparable<T>> minOf(a: T, vararg other: T): T ``` ``` fun minOf(a: Byte, vararg other: Byte): Byte ``` ``` fun minOf(a: Short, vararg other: Short): Short ``` ``` fun minOf(a: Int, vararg other: Int): Int ``` ``` fun minOf(a: Long, vararg other: Long): Long ``` ``` fun minOf(a: Float, vararg other: Float): Float ``` ``` fun minOf(a: Double, vararg other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [naturalOrder](natural-order) Returns a comparator that compares [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects in natural order. ``` fun <T : Comparable<T>> naturalOrder(): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nullsFirst](nulls-first) Extends the given [comparator](nulls-first#kotlin.comparisons%24nullsFirst(kotlin.Comparator((kotlin.comparisons.nullsFirst.T)))/comparator) of non-nullable values to a comparator of nullable values considering `null` value less than any other value. Non-null values are compared with the provided [comparator](nulls-first#kotlin.comparisons%24nullsFirst(kotlin.Comparator((kotlin.comparisons.nullsFirst.T)))/comparator). ``` fun <T : Any> nullsFirst(     comparator: Comparator<in T> ): Comparator<T?> ``` Provides a comparator of nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values considering `null` value less than any other value. Non-null values are compared according to their [natural order](natural-order). ``` fun <T : Comparable<T>> nullsFirst(): Comparator<T?> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [nullsLast](nulls-last) Extends the given [comparator](nulls-last#kotlin.comparisons%24nullsLast(kotlin.Comparator((kotlin.comparisons.nullsLast.T)))/comparator) of non-nullable values to a comparator of nullable values considering `null` value greater than any other value. Non-null values are compared with the provided [comparator](nulls-last#kotlin.comparisons%24nullsLast(kotlin.Comparator((kotlin.comparisons.nullsLast.T)))/comparator). ``` fun <T : Any> nullsLast(     comparator: Comparator<in T> ): Comparator<T?> ``` Provides a comparator of nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values considering `null` value greater than any other value. Non-null values are compared according to their [natural order](natural-order). ``` fun <T : Comparable<T>> nullsLast(): Comparator<T?> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <reversed> Returns a comparator that imposes the reverse ordering of this comparator. ``` fun <T> Comparator<T>.reversed(): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverseOrder](reverse-order) Returns a comparator that compares [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects in reversed natural order. ``` fun <T : Comparable<T>> reverseOrder(): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <then> Combines this comparator and the given [comparator](then#kotlin.comparisons%24then(kotlin.Comparator((kotlin.comparisons.then.T)),%20kotlin.Comparator((kotlin.comparisons.then.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` infix fun <T> Comparator<T>.then(     comparator: Comparator<in T> ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenBy](then-by) Creates a comparator comparing values after the primary comparator defined them equal. It uses the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> Comparator<T>.thenBy(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator comparing values after the primary comparator defined them equal. It uses the [selector](then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/selector) function to transform values and then compares them with the given [comparator](then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/comparator). ``` fun <T, K> Comparator<T>.thenBy(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenByDescending](then-by-descending) Creates a descending comparator using the primary comparator and the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> Comparator<T>.thenByDescending(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a descending comparator comparing values after the primary comparator defined them equal. It uses the [selector](then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/selector) function to transform values and then compares them with the given [comparator](then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/comparator). ``` fun <T, K> Comparator<T>.thenByDescending(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenComparator](then-comparator) Creates a comparator using the primary comparator and function to calculate a result of comparison. ``` fun <T> Comparator<T>.thenComparator(     comparison: (a: T, b: T) -> Int ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenDescending](then-descending) Combines this comparator and the given [comparator](then-descending#kotlin.comparisons%24thenDescending(kotlin.Comparator((kotlin.comparisons.thenDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenDescending.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` infix fun <T> Comparator<T>.thenDescending(     comparator: Comparator<in T> ): Comparator<T> ```
programming_docs
kotlin naturalOrder naturalOrder ============ [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [naturalOrder](natural-order) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> naturalOrder(): Comparator<T> ``` Returns a comparator that compares [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects in natural order. The natural order of a `Comparable` type here means the order established by its `compareTo` function. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val lengthThenNatural = compareBy<String> { it.length } .then(naturalOrder()) val sorted = list.sortedWith(lengthThenNatural) println(sorted) // [a, b, aa, bb] //sampleEnd } ``` kotlin thenBy thenBy ====== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [thenBy](then-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Comparator<T>.thenBy(     crossinline selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator comparing values after the primary comparator defined them equal. It uses the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val lengthComparator = compareBy<String> { it.length } println(list.sortedWith(lengthComparator)) // [b, a, aa, bb] val lengthThenString = lengthComparator.thenBy { it } println(list.sortedWith(lengthThenString)) // [a, b, aa, bb] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Comparator<T>.thenBy(     comparator: Comparator<in K>,     crossinline selector: (T) -> K ): Comparator<T> ``` Creates a comparator comparing values after the primary comparator defined them equal. It uses the [selector](then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/selector) function to transform values and then compares them with the given [comparator](then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("A", "aa", "b", "bb", "a") val lengthComparator = compareBy<String> { it.length } println(list.sortedWith(lengthComparator)) // [A, b, a, aa, bb] val lengthThenCaseInsensitive = lengthComparator .thenBy(String.CASE_INSENSITIVE_ORDER) { it } println(list.sortedWith(lengthThenCaseInsensitive)) // [A, a, b, aa, bb] //sampleEnd } ``` kotlin then then ==== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / <then> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Comparator<T>.then(     comparator: Comparator<in T> ): Comparator<T> ``` Combines this comparator and the given [comparator](then#kotlin.comparisons%24then(kotlin.Comparator((kotlin.comparisons.then.T)),%20kotlin.Comparator((kotlin.comparisons.then.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("A", "aa", "b", "bb", "a") val lengthThenCaseInsensitive = compareBy<String> { it.length } .then(String.CASE_INSENSITIVE_ORDER) val sorted = list.sortedWith(lengthThenCaseInsensitive) println(sorted) // [A, a, b, aa, bb] //sampleEnd } ``` kotlin thenDescending thenDescending ============== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [thenDescending](then-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <T> Comparator<T>.thenDescending(     comparator: Comparator<in T> ): Comparator<T> ``` Combines this comparator and the given [comparator](then-descending#kotlin.comparisons%24thenDescending(kotlin.Comparator((kotlin.comparisons.thenDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenDescending.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("A", "aa", "b", "bb", "a") val lengthThenCaseInsensitive = compareBy<String> { it.length } .thenDescending(String.CASE_INSENSITIVE_ORDER) val sorted = list.sortedWith(lengthThenCaseInsensitive) println(sorted) // [b, A, a, bb, aa] //sampleEnd } ``` kotlin compareByDescending compareByDescending =================== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [compareByDescending](compare-by-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> compareByDescending(     crossinline selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a descending comparator using the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val sorted = list.sortedWith(compareByDescending { it.length }) println(sorted) // [aa, bb, b, a] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> compareByDescending(     comparator: Comparator<in K>,     crossinline selector: (T) -> K ): Comparator<T> ``` Creates a descending comparator using the [selector](compare-by-descending#kotlin.comparisons%24compareByDescending(kotlin.Comparator((kotlin.comparisons.compareByDescending.K)),%20kotlin.Function1((kotlin.comparisons.compareByDescending.T,%20kotlin.comparisons.compareByDescending.K)))/selector) function to transform values being compared and then applying the specified [comparator](compare-by-descending#kotlin.comparisons%24compareByDescending(kotlin.Comparator((kotlin.comparisons.compareByDescending.K)),%20kotlin.Function1((kotlin.comparisons.compareByDescending.T,%20kotlin.comparisons.compareByDescending.K)))/comparator) to compare transformed values. Note that an order of [comparator](compare-by-descending#kotlin.comparisons%24compareByDescending(kotlin.Comparator((kotlin.comparisons.compareByDescending.K)),%20kotlin.Function1((kotlin.comparisons.compareByDescending.T,%20kotlin.comparisons.compareByDescending.K)))/comparator) is reversed by this wrapper. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf('B', 'a', 'A', 'b') val sorted = list.sortedWith( compareByDescending(String.CASE_INSENSITIVE_ORDER) { v -> v.toString() } ) println(sorted) // [B, b, a, A] //sampleEnd } ``` kotlin maxOf maxOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [maxOf](max-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T : Comparable<T>> maxOf(a: T, b: T): T ``` Returns the greater of two values. If values are equal, returns the first one. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun maxOf(a: Byte, b: Byte): Byte ``` ``` fun maxOf(a: Short, b: Short): Short ``` ``` fun maxOf(a: Int, b: Int): Int ``` ``` fun maxOf(a: Long, b: Long): Long ``` Returns the greater of two values. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun maxOf(a: Float, b: Float): Float ``` ``` fun maxOf(a: Double, b: Double): Double ``` Returns the greater of two values. If either value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T : Comparable<T>> maxOf(a: T, b: T, c: T): T ``` Returns the greater of three values. If there are multiple equal maximal values, returns the first of them. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun maxOf(a: Byte, b: Byte, c: Byte): Byte ``` ``` fun maxOf(a: Short, b: Short, c: Short): Short ``` ``` fun maxOf(a: Int, b: Int, c: Int): Int ``` ``` fun maxOf(a: Long, b: Long, c: Long): Long ``` Returns the greater of three values. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun maxOf(a: Float, b: Float, c: Float): Float ``` ``` fun maxOf(a: Double, b: Double, c: Double): Double ``` Returns the greater of three values. If any value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> maxOf(     a: T,     b: T,     c: T,     comparator: Comparator<in T> ): T ``` Returns the greater of three values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). If there are multiple equal maximal values, returns the first of them. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> maxOf(a: T, b: T, comparator: Comparator<in T>): T ``` Returns the greater of two values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.comparisons.maxOf.T,%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). If values are equal, returns the first one. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> maxOf(a: T, vararg other: T): T ``` Returns the greater of the given values. If there are multiple equal maximal values, returns the first of them. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun maxOf(a: Byte, vararg other: Byte): Byte ``` ``` fun maxOf(a: Short, vararg other: Short): Short ``` ``` fun maxOf(a: Int, vararg other: Int): Int ``` ``` fun maxOf(a: Long, vararg other: Long): Long ``` Returns the greater of the given values. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun maxOf(a: Float, vararg other: Float): Float ``` ``` fun maxOf(a: Double, vararg other: Double): Double ``` Returns the greater of the given values. If any value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> maxOf(     a: T,     vararg other: T,     comparator: Comparator<in T> ): T ``` Returns the greater of the given values according to the order specified by the given [comparator](max-of#kotlin.comparisons%24maxOf(kotlin.comparisons.maxOf.T,%20kotlin.Array((kotlin.comparisons.maxOf.T)),%20kotlin.Comparator((kotlin.comparisons.maxOf.T)))/comparator). If there are multiple equal maximal values, returns the first of them. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun maxOf(a: UInt, b: UInt): UInt ``` ``` fun maxOf(a: ULong, b: ULong): ULong ``` ``` fun maxOf(a: UByte, b: UByte): UByte ``` ``` fun maxOf(a: UShort, b: UShort): UShort ``` Returns the greater of two values. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun maxOf(a: UInt, b: UInt, c: UInt): UInt ``` ``` fun maxOf(a: ULong, b: ULong, c: ULong): ULong ``` ``` fun maxOf(a: UByte, b: UByte, c: UByte): UByte ``` ``` fun maxOf(a: UShort, b: UShort, c: UShort): UShort ``` Returns the greater of three values. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @ExperimentalUnsignedTypes fun maxOf(     a: UInt,     vararg other: UInt ): UInt ``` ``` @ExperimentalUnsignedTypes fun maxOf(     a: ULong,     vararg other: ULong ): ULong ``` ``` @ExperimentalUnsignedTypes fun maxOf(     a: UByte,     vararg other: UByte ): UByte ``` ``` @ExperimentalUnsignedTypes fun maxOf(     a: UShort,     vararg other: UShort ): UShort ``` Returns the greater of the given values. kotlin nullsLast nullsLast ========= [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [nullsLast](nulls-last) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> nullsLast(     comparator: Comparator<in T> ): Comparator<T?> ``` Extends the given [comparator](nulls-last#kotlin.comparisons%24nullsLast(kotlin.Comparator((kotlin.comparisons.nullsLast.T)))/comparator) of non-nullable values to a comparator of nullable values considering `null` value greater than any other value. Non-null values are compared with the provided [comparator](nulls-last#kotlin.comparisons%24nullsLast(kotlin.Comparator((kotlin.comparisons.nullsLast.T)))/comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(4, null, 1, -2, 3) val nullsFirstList = list.sortedWith(nullsFirst(reverseOrder())) println(nullsFirstList) // [null, 4, 3, 1, -2] val nullsLastList = list.sortedWith(nullsLast(reverseOrder())) println(nullsLastList) // [4, 3, 1, -2, null] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> nullsLast(): Comparator<T?> ``` Provides a comparator of nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values considering `null` value greater than any other value. Non-null values are compared according to their [natural order](natural-order). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(4, null, -1, 1) val nullsFirstList = list.sortedWith(nullsFirst()) println(nullsFirstList) // [null, -1, 1, 4] val nullsLastList = list.sortedWith(nullsLast()) println(nullsLastList) // [-1, 1, 4, null] //sampleEnd } ``` kotlin nullsFirst nullsFirst ========== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [nullsFirst](nulls-first) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> nullsFirst(     comparator: Comparator<in T> ): Comparator<T?> ``` Extends the given [comparator](nulls-first#kotlin.comparisons%24nullsFirst(kotlin.Comparator((kotlin.comparisons.nullsFirst.T)))/comparator) of non-nullable values to a comparator of nullable values considering `null` value less than any other value. Non-null values are compared with the provided [comparator](nulls-first#kotlin.comparisons%24nullsFirst(kotlin.Comparator((kotlin.comparisons.nullsFirst.T)))/comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(4, null, 1, -2, 3) val nullsFirstList = list.sortedWith(nullsFirst(reverseOrder())) println(nullsFirstList) // [null, 4, 3, 1, -2] val nullsLastList = list.sortedWith(nullsLast(reverseOrder())) println(nullsLastList) // [4, 3, 1, -2, null] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> nullsFirst(): Comparator<T?> ``` Provides a comparator of nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values considering `null` value less than any other value. Non-null values are compared according to their [natural order](natural-order). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(4, null, -1, 1) val nullsFirstList = list.sortedWith(nullsFirst()) println(nullsFirstList) // [null, -1, 1, 4] val nullsLastList = list.sortedWith(nullsLast()) println(nullsLastList) // [-1, 1, 4, null] //sampleEnd } ``` kotlin thenByDescending thenByDescending ================ [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [thenByDescending](then-by-descending) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Comparator<T>.thenByDescending(     crossinline selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a descending comparator using the primary comparator and the function to transform value to a [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instance for comparison. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val lengthComparator = compareBy<String> { it.length } println(list.sortedWith(lengthComparator)) // [b, a, aa, bb] val lengthThenStringDesc = lengthComparator.thenByDescending { it } println(list.sortedWith(lengthThenStringDesc)) // [b, a, bb, aa] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> Comparator<T>.thenByDescending(     comparator: Comparator<in K>,     crossinline selector: (T) -> K ): Comparator<T> ``` Creates a descending comparator comparing values after the primary comparator defined them equal. It uses the [selector](then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/selector) function to transform values and then compares them with the given [comparator](then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("A", "aa", "b", "bb", "a") val lengthComparator = compareBy<String> { it.length } println(list.sortedWith(lengthComparator)) // [A, b, a, aa, bb] val lengthThenCaseInsensitive = lengthComparator .thenByDescending(String.CASE_INSENSITIVE_ORDER) { it } println(list.sortedWith(lengthThenCaseInsensitive)) // [b, A, a, bb, aa] //sampleEnd } ``` kotlin minOf minOf ===== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [minOf](min-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T : Comparable<T>> minOf(a: T, b: T): T ``` Returns the smaller of two values. If values are equal, returns the first one. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun minOf(a: Byte, b: Byte): Byte ``` ``` fun minOf(a: Short, b: Short): Short ``` ``` fun minOf(a: Int, b: Int): Int ``` ``` fun minOf(a: Long, b: Long): Long ``` Returns the smaller of two values. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun minOf(a: Float, b: Float): Float ``` ``` fun minOf(a: Double, b: Double): Double ``` Returns the smaller of two values. If either value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T : Comparable<T>> minOf(a: T, b: T, c: T): T ``` Returns the smaller of three values. If there are multiple equal minimal values, returns the first of them. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun minOf(a: Byte, b: Byte, c: Byte): Byte ``` ``` fun minOf(a: Short, b: Short, c: Short): Short ``` ``` fun minOf(a: Int, b: Int, c: Int): Int ``` ``` fun minOf(a: Long, b: Long, c: Long): Long ``` Returns the smaller of three values. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun minOf(a: Float, b: Float, c: Float): Float ``` ``` fun minOf(a: Double, b: Double, c: Double): Double ``` Returns the smaller of three values. If any value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> minOf(     a: T,     b: T,     c: T,     comparator: Comparator<in T> ): T ``` Returns the smaller of three values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). If there are multiple equal minimal values, returns the first of them. **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` fun <T> minOf(a: T, b: T, comparator: Comparator<in T>): T ``` Returns the smaller of two values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.comparisons.minOf.T,%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). If values are equal, returns the first one. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Comparable<T>> minOf(a: T, vararg other: T): T ``` Returns the smaller of the given values. If there are multiple equal minimal values, returns the first of them. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun minOf(a: Byte, vararg other: Byte): Byte ``` ``` fun minOf(a: Short, vararg other: Short): Short ``` ``` fun minOf(a: Int, vararg other: Int): Int ``` ``` fun minOf(a: Long, vararg other: Long): Long ``` Returns the smaller of the given values. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun minOf(a: Float, vararg other: Float): Float ``` ``` fun minOf(a: Double, vararg other: Double): Double ``` Returns the smaller of the given values. If any value is `NaN`, returns `NaN`. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T> minOf(     a: T,     vararg other: T,     comparator: Comparator<in T> ): T ``` Returns the smaller of the given values according to the order specified by the given [comparator](min-of#kotlin.comparisons%24minOf(kotlin.comparisons.minOf.T,%20kotlin.Array((kotlin.comparisons.minOf.T)),%20kotlin.Comparator((kotlin.comparisons.minOf.T)))/comparator). If there are multiple equal minimal values, returns the first of them. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun minOf(a: UInt, b: UInt): UInt ``` ``` fun minOf(a: ULong, b: ULong): ULong ``` ``` fun minOf(a: UByte, b: UByte): UByte ``` ``` fun minOf(a: UShort, b: UShort): UShort ``` Returns the smaller of two values. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun minOf(a: UInt, b: UInt, c: UInt): UInt ``` ``` fun minOf(a: ULong, b: ULong, c: ULong): ULong ``` ``` fun minOf(a: UByte, b: UByte, c: UByte): UByte ``` ``` fun minOf(a: UShort, b: UShort, c: UShort): UShort ``` Returns the smaller of three values. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @ExperimentalUnsignedTypes fun minOf(     a: UInt,     vararg other: UInt ): UInt ``` ``` @ExperimentalUnsignedTypes fun minOf(     a: ULong,     vararg other: ULong ): ULong ``` ``` @ExperimentalUnsignedTypes fun minOf(     a: UByte,     vararg other: UByte ): UByte ``` ``` @ExperimentalUnsignedTypes fun minOf(     a: UShort,     vararg other: UShort ): UShort ``` Returns the smaller of the given values.
programming_docs
kotlin reversed reversed ======== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / <reversed> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Comparator<T>.reversed(): Comparator<T> ``` Returns a comparator that imposes the reverse ordering of this comparator. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("aa", "b", "bb", "a") val lengthThenString = compareBy<String> { it.length }.thenBy { it } val sorted = list.sortedWith(lengthThenString) println(sorted) // [a, b, aa, bb] val sortedReversed = list.sortedWith(lengthThenString.reversed()) println(sortedReversed) // [bb, aa, b, a] //sampleEnd } ``` kotlin thenComparator thenComparator ============== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [thenComparator](then-comparator) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> Comparator<T>.thenComparator(     crossinline comparison: (a: T, b: T) -> Int ): Comparator<T> ``` Creates a comparator using the primary comparator and function to calculate a result of comparison. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf("c" to 1, "b" to 2, "a" to 1, "d" to 0, null to 0) val valueComparator = compareBy<Pair<String?, Int>> { it.second } val map1 = list.sortedWith(valueComparator).toMap() println(map1) // {d=0, null=0, c=1, a=1, b=2} val valueThenKeyComparator = valueComparator .thenComparator({ a, b -> compareValues(a.first, b.first) }) val map2 = list.sortedWith(valueThenKeyComparator).toMap() println(map2) // {null=0, d=0, a=1, c=1, b=2} //sampleEnd } ``` kotlin compareValuesBy compareValuesBy =============== [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [compareValuesBy](compare-values-by) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> compareValuesBy(     a: T,     b: T,     vararg selectors: (T) -> Comparable<*>? ): Int ``` Compares two values using the specified functions [selectors](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/selectors) to calculate the result of the comparison. The functions are called sequentially, receive the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/b) and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. As soon as the [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances returned by a function for [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Array((kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))))/b) values do not compare as equal, the result of that comparison is returned. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun compareLengthThenString(a: String, b: String): Int = compareValuesBy(a, b, { it.length }, { it }) println("compareLengthThenString(\"b\", \"aa\") < 0 is ${compareLengthThenString("b", "aa") < 0}") // true println("compareLengthThenString(\"a\", \"b\") < 0 is ${compareLengthThenString("a", "b") < 0}") // true println("compareLengthThenString(\"b\", \"a\") > 0 is ${compareLengthThenString("b", "a") > 0}") // true println("compareLengthThenString(\"a\", \"a\") == 0 is ${compareLengthThenString("a", "a") == 0}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> compareValuesBy(     a: T,     b: T,     selector: (T) -> Comparable<*>? ): Int ``` Compares two values using the specified [selector](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/selector) function to calculate the result of the comparison. The function is applied to the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparable?((kotlin.Any?)))))/b) and return [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects. The result of comparison of these [Comparable](../kotlin/-comparable/index#kotlin.Comparable) instances is returned. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun compareLength(a: String, b: String): Int = compareValuesBy(a, b) { it.length } println("compareLength(\"a\", \"b\") == 0 is ${compareLength("a", "b") == 0}") // true println("compareLength(\"bb\", \"a\") > 0 is ${compareLength("bb", "a") > 0}") // true println("compareLength(\"a\", \"bb\") < 0 is ${compareLength("a", "bb") < 0}") // true //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, K> compareValuesBy(     a: T,     b: T,     comparator: Comparator<in K>,     selector: (T) -> K ): Int ``` Compares two values using the specified [selector](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/selector) function to calculate the result of the comparison. The function is applied to the given values [a](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/a) and [b](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/b) and return objects of type K which are then being compared with the given [comparator](compare-values-by#kotlin.comparisons%24compareValuesBy(kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.T,%20kotlin.Comparator((kotlin.comparisons.compareValuesBy.K)),%20kotlin.Function1((kotlin.comparisons.compareValuesBy.T,%20kotlin.comparisons.compareValuesBy.K)))/comparator). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun compareInsensitiveOrder(a: Char, b: Char): Int = compareValuesBy(a, b, String.CASE_INSENSITIVE_ORDER, { c -> c.toString() }) println("compareInsensitiveOrder('a', 'a') == 0 is ${compareInsensitiveOrder('a', 'a') == 0}") // true println("compareInsensitiveOrder('a', 'A') == 0 is ${compareInsensitiveOrder('a', 'A') == 0}") // true println("compareInsensitiveOrder('a', 'b') < 0 is ${compareInsensitiveOrder('a', 'b') < 0}") // true println("compareInsensitiveOrder('A', 'b') < 0 is ${compareInsensitiveOrder('A', 'b') < 0}") // true println("compareInsensitiveOrder('b', 'a') > 0 is ${compareInsensitiveOrder('b', 'a') > 0}") // true //sampleEnd } ``` kotlin compareValues compareValues ============= [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [compareValues](compare-values) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<*>> compareValues(a: T?, b: T?): Int ``` Compares two nullable [Comparable](../kotlin/-comparable/index#kotlin.Comparable) values. Null is considered less than any value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart println("compareValues(null, 1) < 0 is ${compareValues(null, 1) < 0}") // true println("compareValues(1, 2) < 0 is ${compareValues(1, 2) < 0}") // true println("compareValues(2, 1) > 0 is ${compareValues(2, 1) > 0}") // true println("compareValues(1, 1) == 0 is ${compareValues(1, 1) == 0}") // true //sampleEnd } ``` kotlin reverseOrder reverseOrder ============ [kotlin-stdlib](../../../../../index) / [kotlin.comparisons](index) / [reverseOrder](reverse-order) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Comparable<T>> reverseOrder(): Comparator<T> ``` Returns a comparator that compares [Comparable](../kotlin/-comparable/index#kotlin.Comparable) objects in reversed natural order. The natural order of a `Comparable` type here means the order established by its `compareTo` function. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val list = listOf(4, null, 1, -2, 3) val nullsFirstList = list.sortedWith(nullsFirst(reverseOrder())) println(nullsFirstList) // [null, 4, 3, 1, -2] val nullsLastList = list.sortedWith(nullsLast(reverseOrder())) println(nullsLastList) // [4, 3, 1, -2, null] //sampleEnd } ``` kotlin javaType javaType ======== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / [javaType](java-type) **Platform and version requirements:** JVM (1.4) ``` @ExperimentalStdlibApi 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. This function is experimental because not all the features are supported yet, and behavior might change in corner cases. In particular, the following is not supported correctly or at all: * declaration-site variance * variance of types annotated with [JvmSuppressWildcards](../kotlin.jvm/-jvm-suppress-wildcards/index#kotlin.jvm.JvmSuppressWildcards) * obtaining the containing declaration of a type parameter ([TypeVariable.getGenericDeclaration](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html#getGenericDeclaration--)) * annotations of type parameters and their bounds ([TypeVariable.getAnnotation](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getAnnotation-java.lang.Class-), [TypeVariable.getAnnotations](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getAnnotations--), [TypeVariable.getDeclaredAnnotations](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedElement.html#getDeclaredAnnotations--), [TypeVariable.getAnnotatedBounds](https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/TypeVariable.html#getAnnotatedBounds--)) kotlin Package kotlin.reflect Package kotlin.reflect ====================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) Runtime API for [Kotlin reflection](../../../../../docs/reflection) Types ----- **Platform and version requirements:** JVM (1.0), Native (1.0) #### [KAnnotatedElement](-k-annotated-element/index) Represents an annotated element and allows to obtain its annotations. See the [Kotlin language documentation](../../../../../docs/annotations) for more information. ``` interface KAnnotatedElement ``` #### [KCallable](-k-callable/index) Represents a callable entity, such as a function or a property. **Platform and version requirements:** JS (1.1) ``` interface KCallable<out R> ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KCallable<out R> : KAnnotatedElement ``` #### [KClass](-k-class/index) Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../docs/reflection#class-references) for more information. **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KClassifier](-k-classifier) A classifier is either a class or a type parameter. ``` interface KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [KDeclarationContainer](-k-declaration-container/index) Represents an entity which may contain declarations of any other entities, such as a class or a package. ``` interface KDeclarationContainer ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KFunction](-k-function/index) Represents a function with introspection capabilities. ``` interface KFunction<out R> : KCallable<R>, Function<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty](-k-mutable-property/index) Represents a property declared as a `var`. ``` interface KMutableProperty<V> : KProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty0](-k-mutable-property0/index) Represents a `var`-property without any kind of receiver. ``` interface KMutableProperty0<V> :      KProperty0<V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty1](-k-mutable-property1/index) Represents a `var`-property, operations on which take one receiver as a parameter. ``` interface KMutableProperty1<T, V> :      KProperty1<T, V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty2](-k-mutable-property2/index) Represents a `var`-property, operations on which take two receivers as parameters. ``` interface KMutableProperty2<D, E, V> :      KProperty2<D, E, V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0) #### [KParameter](-k-parameter/index) Represents a parameter passed to a function or a property getter/setter, including `this` and extension receiver parameters. ``` interface KParameter : KAnnotatedElement ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty](-k-property/index) Represents a property, such as a named `val` or `var` declaration. Instances of this class are obtainable by the `::` operator. ``` interface KProperty<out V> : KCallable<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty0](-k-property0/index) Represents a property without any kind of receiver. Such property is either originally declared in a receiverless context such as a package, or has the receiver bound to it. ``` interface KProperty0<out V> : KProperty<V>, () -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty1](-k-property1/index) Represents a property, operations on which take one receiver as a parameter. ``` interface KProperty1<T, out V> : KProperty<V>, (T) -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty2](-k-property2/index) Represents a property, operations on which take two receivers as parameters, such as an extension property declared in a class. ``` interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V ``` #### [KType](-k-type/index) Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability. **Platform and version requirements:** JS (1.1), Native (1.3) ``` interface KType ``` **Platform and version requirements:** JVM (1.0) ``` interface KType : KAnnotatedElement ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KTypeParameter](-k-type-parameter/index) Represents a declaration of a type parameter of a class or a callable. See the [Kotlin language documentation](../../../../../docs/generics#generics) for more information. ``` interface KTypeParameter : KClassifier ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KTypeProjection](-k-type-projection/index) Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`. ``` data class KTypeProjection ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KVariance](-k-variance/index) Represents variance applied to a type parameter on the declaration site (*declaration-site variance*), or to a type in a projection (*use-site variance*). ``` enum class KVariance ``` **Platform and version requirements:** JVM (1.1) #### [KVisibility](-k-visibility/index) Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code. Visibility can be changed with one of the following modifiers: `public`, `protected`, `internal`, `private`. ``` enum class KVisibility ``` Annotations ----------- **Platform and version requirements:** JS (1.1), Native (1.1) #### [AssociatedObjectKey](-associated-object-key/index) Makes the annotated annotation class an associated object key. ``` annotation class AssociatedObjectKey ``` **Platform and version requirements:** JS (1.1), Native (1.1) #### [ExperimentalAssociatedObjects](-experimental-associated-objects/index) The experimental marker for associated objects API. ``` annotation class ExperimentalAssociatedObjects ``` Properties ---------- **Platform and version requirements:** JVM (1.4) #### [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. ``` val KType.javaType: Type ``` Functions --------- **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### <cast> Casts the given [value](cast#kotlin.reflect%24cast(kotlin.reflect.KClass((kotlin.reflect.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](-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:** JS (1.1), Native (1.1) #### [findAssociatedObject](find-associated-object) If [T](find-associated-object#T) is an @[AssociatedObjectKey](-associated-object-key/index#kotlin.reflect.AssociatedObjectKey)-annotated annotation class and [this](find-associated-object/-this-) class is annotated with @[T](find-associated-object#T) (`S::class`), returns object `S`. ``` fun <T : Annotation> KClass<*>.findAssociatedObject(): Any? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [safeCast](safe-cast) Casts the given [value](safe-cast#kotlin.reflect%24safeCast(kotlin.reflect.KClass((kotlin.reflect.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](-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.6), JS (1.6), Native (1.6) #### [typeOf](type-of) Returns a runtime representation of the given reified type [T](type-of#T) as an instance of [KType](-k-type/index#kotlin.reflect.KType). ``` fun <T> typeOf(): KType ```
programming_docs
kotlin typeOf typeOf ====== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / [typeOf](type-of) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun <reified T> typeOf(): KType ``` Returns a runtime representation of the given reified type [T](type-of#T) as an instance of [KType](-k-type/index#kotlin.reflect.KType). Note that on JVM, the created type has no annotations (KType.annotations returns an empty list) even if the type in the source code is annotated. Support for type annotations might be added in a future version. kotlin cast cast ==== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / <cast> **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Any> KClass<T>.cast(value: Any?): T ``` Casts the given [value](cast#kotlin.reflect%24cast(kotlin.reflect.KClass((kotlin.reflect.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](-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. This is an experimental function that behaves as a similar function from kotlin.reflect.full on JVM. **See Also** [KClass.isInstance](-k-class/is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)) [KClass.safeCast](safe-cast) kotlin safeCast safeCast ======== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / [safeCast](safe-cast) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun <T : Any> KClass<T>.safeCast(value: Any?): T? ``` Casts the given [value](safe-cast#kotlin.reflect%24safeCast(kotlin.reflect.KClass((kotlin.reflect.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](-k-class/index#kotlin.reflect.KClass) object. Returns `null` if the value is `null` or if it is not an instance of this class. This is an experimental function that behaves as a similar function from kotlin.reflect.full on JVM. **See Also** [KClass.isInstance](-k-class/is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)) [KClass.cast](cast) kotlin findAssociatedObject findAssociatedObject ==================== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / [findAssociatedObject](find-associated-object) **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun <reified T : Annotation> KClass<*>.findAssociatedObject(): Any? ``` If [T](find-associated-object#T) is an @[AssociatedObjectKey](-associated-object-key/index#kotlin.reflect.AssociatedObjectKey)-annotated annotation class and [this](find-associated-object/-this-) class is annotated with @[T](find-associated-object#T) (`S::class`), returns object `S`. Otherwise returns `null`. kotlin KClassifier KClassifier =========== [kotlin-stdlib](../../../../../index) / [kotlin.reflect](index) / [KClassifier](-k-classifier) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` interface KClassifier ``` A classifier is either a class or a type parameter. **See Also** [KClass](-k-class/index#kotlin.reflect.KClass) [KTypeParameter](-k-type-parameter/index) Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [starProjectedType](../kotlin.reflect.full/star-projected-type) Creates an instance of [KType](-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 ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [createType](../kotlin.reflect.full/create-type) Creates a [KType](-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 ``` Inheritors ---------- #### [KClass](-k-class/index) Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../docs/reflection#class-references) for more information. **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KTypeParameter](-k-type-parameter/index) Represents a declaration of a type parameter of a class or a callable. See the [Kotlin language documentation](../../../../../docs/generics#generics) for more information. ``` interface KTypeParameter : KClassifier ``` kotlin AssociatedObjectKey AssociatedObjectKey =================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [AssociatedObjectKey](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class AssociatedObjectKey ``` Makes the annotated annotation class an associated object key. An associated object key annotation should have single [KClass](../-k-class/index#kotlin.reflect.KClass) parameter. When applied to a class with reference to an object declaration as an argument, it binds the object to the class, making this binding discoverable at runtime using findAssociatedObject. Constructors ------------ **Platform and version requirements:** JS (1.1), Native (1.1) #### [<init>](-init-) Makes the annotated annotation class an associated object key. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [AssociatedObjectKey](index) / [<init>](-init-) **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>() ``` Makes the annotated annotation class an associated object key. An associated object key annotation should have single [KClass](../-k-class/index#kotlin.reflect.KClass) parameter. When applied to a class with reference to an object declaration as an argument, it binds the object to the class, making this binding discoverable at runtime using findAssociatedObject. kotlin KFunction KFunction ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KFunction<out R> : KCallable<R>, Function<R> ``` Represents a function with introspection capabilities. Properties ---------- **Platform and version requirements:** JVM (1.1) #### [isExternal](is-external) `true` if this function is `external`. See the [Kotlin language documentation](../../../../../../docs/java-interop#using-jni-with-kotlin) for more information. ``` abstract val isExternal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInfix](is-infix) `true` if this function is `infix`. See the [Kotlin language documentation](../../../../../../docs/functions#infix-notation) for more information. ``` abstract val isInfix: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInline](is-inline) `true` if this function is `inline`. See the [Kotlin language documentation](../../../../../../docs/inline-functions) for more information. ``` abstract val isInline: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOperator](is-operator) `true` if this function is `operator`. See the [Kotlin language documentation](../../../../../../docs/operator-overloading) for more information. ``` abstract val isOperator: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSuspend](is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [isAbstract](../-k-callable/is-abstract) `true` if this callable is `abstract`. ``` abstract val isAbstract: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isFinal](../-k-callable/is-final) `true` if this callable is `final`. ``` abstract val isFinal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOpen](../-k-callable/is-open) `true` if this callable is `open`. ``` abstract val isOpen: Boolean ``` **Platform and version requirements:** JVM (1.3) #### [isSuspend](../-k-callable/is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [parameters](../-k-callable/parameters) Parameters required to make a call to this callable. If this callable requires a `this` instance or an extension receiver parameter, they come first in the list in that order. ``` abstract val parameters: List<KParameter> ``` **Platform and version requirements:** JVM (1.1) #### [typeParameters](../-k-callable/type-parameters) The list of type parameters of this callable. ``` abstract val typeParameters: List<KTypeParameter> ``` **Platform and version requirements:** JVM (1.1) #### [visibility](../-k-callable/visibility) Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin. ``` abstract val visibility: KVisibility? ``` Inherited Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [call](../-k-callable/call) Calls this callable with the specified list of arguments and returns the result. Throws an exception if the number of specified arguments is not equal to the size of [parameters](../-k-callable/parameters), or if their types do not match the types of the parameters. ``` abstract fun call(vararg args: Any?): R ``` **Platform and version requirements:** JVM (1.0) #### [callBy](../-k-callable/call-by) Calls this callable with the specified mapping of parameters to arguments and returns the result. If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional](../-k-parameter/is-optional)), or its type does not match the type of the provided value, an exception is thrown. ``` abstract fun callBy(args: Map<KParameter, Any?>): R ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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) #### [javaMethod](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](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>? ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [Getter](../-k-property/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Accessor<V>, KFunction<V> ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../-k-mutable-property/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit> ``` kotlin isOperator isOperator ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) / [isOperator](is-operator) **Platform and version requirements:** JVM (1.1) ``` abstract val isOperator: Boolean ``` `true` if this function is `operator`. See the [Kotlin language documentation](../../../../../../docs/operator-overloading) for more information. kotlin isExternal isExternal ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) / [isExternal](is-external) **Platform and version requirements:** JVM (1.1) ``` abstract val isExternal: Boolean ``` `true` if this function is `external`. See the [Kotlin language documentation](../../../../../../docs/java-interop#using-jni-with-kotlin) for more information. kotlin isSuspend isSuspend ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) / [isSuspend](is-suspend) **Platform and version requirements:** JVM (1.1) ``` abstract val isSuspend: Boolean ``` Overrides [KCallable.isSuspend](../-k-callable/is-suspend) `true` if this is a suspending function. kotlin isInfix isInfix ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) / [isInfix](is-infix) **Platform and version requirements:** JVM (1.1) ``` abstract val isInfix: Boolean ``` `true` if this function is `infix`. See the [Kotlin language documentation](../../../../../../docs/functions#infix-notation) for more information. kotlin isInline isInline ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KFunction](index) / [isInline](is-inline) **Platform and version requirements:** JVM (1.1) ``` abstract val isInline: Boolean ``` `true` if this function is `inline`. See the [Kotlin language documentation](../../../../../../docs/inline-functions) for more information. kotlin KType KType ===== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KType](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` interface KType ``` **Platform and version requirements:** JVM (1.0) ``` interface KType : KAnnotatedElement ``` Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability. Properties ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### <arguments> Type arguments passed for the parameters of the classifier in this type. For example, in the type `Array<out Number>` the only type argument is `out Number`. ``` abstract val arguments: List<KTypeProjection> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### <classifier> The declaration of the classifier used in this type. For example, in the type `List<String>` the classifier would be the [KClass](../-k-class/index#kotlin.reflect.KClass) instance for [List](../../kotlin.collections/-list/index#kotlin.collections.List). ``` abstract val classifier: KClassifier? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isMarkedNullable](is-marked-nullable) `true` if this type was marked nullable in the source code. ``` abstract val isMarkedNullable: Boolean ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotations](../-k-annotated-element/annotations) Annotations which are present on this element. ``` abstract val annotations: List<Annotation> ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [javaType](../../kotlin.reflect.jvm/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.4) #### [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. ``` val KType.javaType: Type ``` **Platform and version requirements:** JVM (1.1) #### [jvmErasure](../../kotlin.reflect.jvm/jvm-erasure) Returns the [KClass](../-k-class/index#kotlin.reflect.KClass) instance representing the runtime class to which this type is erased to on JVM. ``` val KType.jvmErasure: KClass<*> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSubtypeOf](../../kotlin.reflect.full/is-subtype-of) Returns `true` if `this` type is the same or is a subtype of [other](../../kotlin.reflect.full/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) #### [isSupertypeOf](../../kotlin.reflect.full/is-supertype-of) Returns `true` if `this` type is the same or is a supertype of [other](../../kotlin.reflect.full/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) #### [withNullability](../../kotlin.reflect.full/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 isMarkedNullable isMarkedNullable ================ [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KType](index) / [isMarkedNullable](is-marked-nullable) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract val isMarkedNullable: Boolean ``` `true` if this type was marked nullable in the source code. For Kotlin types, it means that `null` value is allowed to be represented by this type. In practice it means that the type was declared with a question mark at the end. For non-Kotlin types, it means the type or the symbol which was declared with this type is annotated with a runtime-retained nullability annotation such as javax.annotation.Nullable. Note that even if [isMarkedNullable](is-marked-nullable#kotlin.reflect.KType%24isMarkedNullable) is false, values of the type can still be `null`. This may happen if it is a type of the type parameter with a nullable upper bound: ``` fun <T> foo(t: T) { // isMarkedNullable == false for t's type, but t can be null here when T = "Any?" } ``` kotlin arguments arguments ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KType](index) / <arguments> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract val arguments: List<KTypeProjection> ``` Type arguments passed for the parameters of the classifier in this type. For example, in the type `Array<out Number>` the only type argument is `out Number`. In case this type is based on an inner class, the returned list contains the type arguments provided for the innermost class first, then its outer class, and so on. For example, in the type `Outer<A, B>.Inner<C, D>` the returned list is `[C, D, A, B]`. kotlin classifier classifier ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KType](index) / <classifier> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract val classifier: KClassifier? ``` The declaration of the classifier used in this type. For example, in the type `List<String>` the classifier would be the [KClass](../-k-class/index#kotlin.reflect.KClass) instance for [List](../../kotlin.collections/-list/index#kotlin.collections.List). Returns `null` if this type is not denotable in Kotlin, for example if it is an intersection type. kotlin KParameter KParameter ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) **Platform and version requirements:** JVM (1.0) ``` interface KParameter : KAnnotatedElement ``` Represents a parameter passed to a function or a property getter/setter, including `this` and extension receiver parameters. Types ----- **Platform and version requirements:** JVM (1.0) #### [Kind](-kind/index) Kind represents a particular position of the parameter declaration in the source code, such as an instance, an extension receiver parameter or a value parameter. ``` enum class Kind ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### [index](--index--) 0-based index of this parameter in the parameter list of its containing callable. ``` abstract val index: Int ``` **Platform and version requirements:** JVM (1.0) #### [isOptional](is-optional) `true` if this parameter is optional and can be omitted when making a call via [KCallable.callBy](../-k-callable/call-by), or `false` otherwise. ``` abstract val isOptional: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isVararg](is-vararg) `true` if this parameter is `vararg`. See the [Kotlin language documentation](../../../../../../docs/functions#variable-number-of-arguments-varargs) for more information. ``` abstract val isVararg: Boolean ``` **Platform and version requirements:** JVM (1.0) #### <kind> Kind of this parameter. ``` abstract val kind: Kind ``` **Platform and version requirements:** JVM (1.0) #### <name> Name of this parameter as it was declared in the source code, or `null` if the parameter has no name or its name is not available at runtime. Examples of nameless parameters include `this` instance for member functions, extension receiver for extension functions or properties, parameters of Java methods compiled without the debug information, and others. ``` abstract val name: String? ``` **Platform and version requirements:** JVM (1.0) #### <type> Type of this parameter. For a `vararg` parameter, this is the type of the corresponding array, not the individual element. ``` abstract val type: KType ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotations](../-k-annotated-element/annotations) Annotations which are present on this element. ``` abstract val annotations: List<Annotation> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` kotlin type type ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / <type> **Platform and version requirements:** JVM (1.0) ``` abstract val type: KType ``` Type of this parameter. For a `vararg` parameter, this is the type of the corresponding array, not the individual element. kotlin isOptional isOptional ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / [isOptional](is-optional) **Platform and version requirements:** JVM (1.0) ``` abstract val isOptional: Boolean ``` `true` if this parameter is optional and can be omitted when making a call via [KCallable.callBy](../-k-callable/call-by), or `false` otherwise. A parameter is optional in any of the two cases: 1. The default value is provided at the declaration of this parameter. 2. The parameter is declared in a member function and one of the corresponding parameters in the super functions is optional. kotlin kind kind ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / <kind> **Platform and version requirements:** JVM (1.0) ``` abstract val kind: Kind ``` Kind of this parameter. kotlin index index ===== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / [index](--index--) **Platform and version requirements:** JVM (1.0) ``` abstract val index: Int ``` 0-based index of this parameter in the parameter list of its containing callable. kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / <name> **Platform and version requirements:** JVM (1.0) ``` abstract val name: String? ``` Name of this parameter as it was declared in the source code, or `null` if the parameter has no name or its name is not available at runtime. Examples of nameless parameters include `this` instance for member functions, extension receiver for extension functions or properties, parameters of Java methods compiled without the debug information, and others. kotlin isVararg isVararg ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KParameter](index) / [isVararg](is-vararg) **Platform and version requirements:** JVM (1.1) ``` abstract val isVararg: Boolean ``` `true` if this parameter is `vararg`. See the [Kotlin language documentation](../../../../../../docs/functions#variable-number-of-arguments-varargs) for more information. kotlin INSTANCE INSTANCE ======== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KParameter](../index) / [Kind](index) / [INSTANCE](-i-n-s-t-a-n-c-e) **Platform and version requirements:** JVM (1.0) ``` INSTANCE ``` Instance required to make a call to the member, or an outer class instance for an inner class constructor. kotlin Kind Kind ==== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KParameter](../index) / [Kind](index) **Platform and version requirements:** JVM (1.0) ``` enum class Kind ``` Kind represents a particular position of the parameter declaration in the source code, such as an instance, an extension receiver parameter or a value parameter. Enum Values ----------- **Platform and version requirements:** JVM (1.0) #### [INSTANCE](-i-n-s-t-a-n-c-e) Instance required to make a call to the member, or an outer class instance for an inner class constructor. **Platform and version requirements:** JVM (1.0) #### [EXTENSION\_RECEIVER](-e-x-t-e-n-s-i-o-n_-r-e-c-e-i-v-e-r) Extension receiver of an extension function or property. **Platform and version requirements:** JVM (1.0) #### [VALUE](-v-a-l-u-e) Ordinary named value parameter. kotlin EXTENSION_RECEIVER EXTENSION\_RECEIVER =================== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KParameter](../index) / [Kind](index) / [EXTENSION\_RECEIVER](-e-x-t-e-n-s-i-o-n_-r-e-c-e-i-v-e-r) **Platform and version requirements:** JVM (1.0) ``` EXTENSION_RECEIVER ``` Extension receiver of an extension function or property. kotlin VALUE VALUE ===== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KParameter](../index) / [Kind](index) / [VALUE](-v-a-l-u-e) **Platform and version requirements:** JVM (1.0) ``` VALUE ``` Ordinary named value parameter. kotlin getter getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) / <getter> **Platform and version requirements:** JVM (1.0) ``` abstract val getter: KProperty2.Getter<D, E, V> ``` Overrides [KProperty.getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. kotlin KProperty2 KProperty2 ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V ``` Represents a property, operations on which take two receivers as parameters, such as an extension property declared in a class. Parameters ---------- `D` - the type of the first receiver. In case of the extension property in a class this is the type of the declaring class of the property, or any subclass of that class. `E` - the type of the second receiver. In case of the extension property in a class this is the type of the extension receiver. `V` - the type of the property value. Types ----- **Platform and version requirements:** JVM (1.0) #### [Getter](-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<D, E, out V> :      KProperty.Getter<V>,     (D, E) -> V ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <getter> The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty2.Getter<D, E, V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty.Getter<V> ``` **Platform and version requirements:** JVM (1.1) #### [isConst](../-k-property/is-const) `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. ``` abstract val isConst: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isLateinit](../-k-property/is-lateinit) `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. ``` abstract val isLateinit: Boolean ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the current value of the property. In case of the extension property in a class, the instance of the class should be passed first and the instance of the extension receiver second. ``` abstract fun get(receiver1: D, receiver2: E): V ``` **Platform and version requirements:** JVM (1.1) #### [getDelegate](get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(receiver1: D, receiver2: E): Any? ``` **Platform and version requirements:** Native (1.3) #### <invoke> ``` abstract operator fun invoke(p1: D, p2: E): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/get-extension-delegate) 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](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty2](../-k-mutable-property2/index) Represents a `var`-property, operations on which take two receivers as parameters. ``` interface KMutableProperty2<D, E, V> :      KProperty2<D, E, V>,     KMutableProperty<V> ``` kotlin invoke invoke ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) / <invoke> **Platform and version requirements:** Native (1.3) ``` abstract operator fun invoke(p1: D, p2: E): V ``` kotlin getDelegate getDelegate =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) / [getDelegate](get-delegate) **Platform and version requirements:** JVM (1.1) ``` abstract fun getDelegate(receiver1: D, receiver2: E): Any? ``` Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. In case of the extension property in a class, the instance of the class should be passed first and the instance of the extension receiver second. Parameters ---------- `receiver1` - the instance of the first receiver. `receiver2` - the instance of the second receiver. **See Also** [kotlin.reflect.full.getExtensionDelegate](../../kotlin.reflect.full/get-extension-delegate)
programming_docs
kotlin Getter Getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) / [Getter](-getter) **Platform and version requirements:** JVM (1.0) ``` interface Getter<D, E, out V> :      KProperty.Getter<V>,     (D, E) -> V ``` Getter of the property is a `get` method declared alongside the property. Can be used as a function that takes an argument of type [D](-getter#D) (the first receiver), an argument of type [E](-getter#E) (the second receiver) and returns the value of the property type [V](-getter#V). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty2](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun get(receiver1: D, receiver2: E): V ``` Returns the current value of the property. In case of the extension property in a class, the instance of the class should be passed first and the instance of the extension receiver second. Parameters ---------- `receiver1` - the instance of the first receiver. `receiver2` - the instance of the second receiver. kotlin STAR STAR ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / [STAR](-s-t-a-r) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val STAR: KTypeProjection ``` Star projection, denoted by the `*` character. For example, in the type `KClass<*>`, `*` is the star projection. See the [Kotlin language documentation](../../../../../../docs/generics#star-projections) for more information. kotlin KTypeProjection KTypeProjection =============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` data class KTypeProjection ``` Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`. Type projection is either the star projection, or an entity consisting of a specific type plus optional variance. See the [Kotlin language documentation](../../../../../../docs/generics#type-projections) for more information. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`. ``` KTypeProjection(variance: KVariance?, type: KType?) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <type> The type specified in the projection, or `null` if this is a star projection. ``` val type: KType? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <variance> The use-site variance specified in the projection, or `null` if this is a star projection. ``` val variance: KVariance? ``` Functions --------- **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 ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [STAR](-s-t-a-r) Star projection, denoted by the `*` character. For example, in the type `KClass<*>`, `*` is the star projection. See the [Kotlin language documentation](../../../../../../docs/generics#star-projections) for more information. ``` val STAR: KTypeProjection ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <contravariant> Creates a contravariant projection of a given type, denoted by the `in` modifier applied to a type. For example, in the type `MutableList<in Number>`, `in Number` is a contravariant projection of the type of class `Number`. ``` fun contravariant(type: KType): KTypeProjection ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <covariant> Creates a covariant projection of a given type, denoted by the `out` modifier applied to a type. For example, in the type `Array<out Number>`, `out Number` is a covariant projection of the type of class `Number`. ``` fun covariant(type: KType): KTypeProjection ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <invariant> Creates an invariant projection of a given type. Invariant projection is just the type itself, without any use-site variance modifiers applied to it. For example, in the type `Set<String>`, `String` is an invariant projection of the type represented by the class `String`. ``` fun invariant(type: KType): KTypeProjection ``` kotlin type type ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / <type> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val type: KType? ``` The type specified in the projection, or `null` if this is a star projection. kotlin variance variance ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / <variance> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val variance: KVariance? ``` The use-site variance specified in the projection, or `null` if this is a star projection. kotlin invariant invariant ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / <invariant> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmStatic fun invariant(type: KType): KTypeProjection ``` Creates an invariant projection of a given type. Invariant projection is just the type itself, without any use-site variance modifiers applied to it. For example, in the type `Set<String>`, `String` is an invariant projection of the type represented by the class `String`. kotlin contravariant contravariant ============= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / <contravariant> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmStatic fun contravariant(type: KType): KTypeProjection ``` Creates a contravariant projection of a given type, denoted by the `in` modifier applied to a type. For example, in the type `MutableList<in Number>`, `in Number` is a contravariant projection of the type of class `Number`. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](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 covariant covariant ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / <covariant> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmStatic fun covariant(type: KType): KTypeProjection ``` Creates a covariant projection of a given type, denoted by the `out` modifier applied to a type. For example, in the type `Array<out Number>`, `out Number` is a covariant projection of the type of class `Number`. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeProjection](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` KTypeProjection(variance: KVariance?, type: KType?) ``` Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`. Type projection is either the star projection, or an entity consisting of a specific type plus optional variance. See the [Kotlin language documentation](../../../../../../docs/generics#type-projections) for more information. kotlin KTypeParameter KTypeParameter ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeParameter](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` interface KTypeParameter : KClassifier ``` Represents a declaration of a type parameter of a class or a callable. See the [Kotlin language documentation](../../../../../../docs/generics#generics) for more information. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isReified](is-reified) `true` if this type parameter is `reified`. See the [Kotlin language documentation](../../../../../../docs/inline-functions#reified-type-parameters) for more information. ``` abstract val isReified: Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <name> The name of this type parameter as it was declared in the source code. ``` abstract val name: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [upperBounds](upper-bounds) Upper bounds, or generic constraints imposed on this type parameter. See the [Kotlin language documentation](../../../../../../docs/generics#upper-bounds) for more information. ``` abstract val upperBounds: List<KType> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <variance> Declaration-site variance of this type parameter. See the [Kotlin language documentation](../../../../../../docs/generics#declaration-site-variance) for more information. ``` abstract val variance: KVariance ``` kotlin variance variance ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeParameter](index) / <variance> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val variance: KVariance ``` Declaration-site variance of this type parameter. See the [Kotlin language documentation](../../../../../../docs/generics#declaration-site-variance) for more information. kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeParameter](index) / <name> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val name: String ``` The name of this type parameter as it was declared in the source code. kotlin isReified isReified ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeParameter](index) / [isReified](is-reified) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val isReified: Boolean ``` `true` if this type parameter is `reified`. See the [Kotlin language documentation](../../../../../../docs/inline-functions#reified-type-parameters) for more information. kotlin upperBounds upperBounds =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KTypeParameter](index) / [upperBounds](upper-bounds) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val upperBounds: List<KType> ``` Upper bounds, or generic constraints imposed on this type parameter. See the [Kotlin language documentation](../../../../../../docs/generics#upper-bounds) for more information. kotlin getter getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty](index) / <getter> **Platform and version requirements:** JVM (1.0) ``` abstract val getter: KProperty.Getter<V> ``` The getter of this property, used to obtain the value of the property. kotlin KProperty KProperty ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KProperty<out V> : KCallable<V> ``` Represents a property, such as a named `val` or `var` declaration. Instances of this class are obtainable by the `::` operator. See the [Kotlin language documentation](../../../../../../docs/reflection) for more information. Parameters ---------- `V` - the type of the property value. Types ----- **Platform and version requirements:** JVM (1.0) #### [Accessor](-accessor/index) Represents a property accessor, which is a `get` or `set` method declared alongside the property. See the [Kotlin language documentation](../../../../../../docs/properties#getters-and-setters) for more information. ``` interface Accessor<out V> ``` **Platform and version requirements:** JVM (1.0) #### [Getter](-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Accessor<V>, KFunction<V> ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <getter> The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty.Getter<V> ``` **Platform and version requirements:** JVM (1.1) #### [isConst](is-const) `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. ``` abstract val isConst: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isLateinit](is-lateinit) `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. ``` abstract val isLateinit: Boolean ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [isAbstract](../-k-callable/is-abstract) `true` if this callable is `abstract`. ``` abstract val isAbstract: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isFinal](../-k-callable/is-final) `true` if this callable is `final`. ``` abstract val isFinal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOpen](../-k-callable/is-open) `true` if this callable is `open`. ``` abstract val isOpen: Boolean ``` **Platform and version requirements:** JVM (1.3) #### [isSuspend](../-k-callable/is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [parameters](../-k-callable/parameters) Parameters required to make a call to this callable. If this callable requires a `this` instance or an extension receiver parameter, they come first in the list in that order. ``` abstract val parameters: List<KParameter> ``` **Platform and version requirements:** JVM (1.1) #### [typeParameters](../-k-callable/type-parameters) The list of type parameters of this callable. ``` abstract val typeParameters: List<KTypeParameter> ``` **Platform and version requirements:** JVM (1.1) #### [visibility](../-k-callable/visibility) Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin. ``` abstract val visibility: KVisibility? ``` Inherited Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [call](../-k-callable/call) Calls this callable with the specified list of arguments and returns the result. Throws an exception if the number of specified arguments is not equal to the size of [parameters](../-k-callable/parameters), or if their types do not match the types of the parameters. ``` abstract fun call(vararg args: Any?): R ``` **Platform and version requirements:** JVM (1.0) #### [callBy](../-k-callable/call-by) Calls this callable with the specified mapping of parameters to arguments and returns the result. If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional](../-k-parameter/is-optional)), or its type does not match the type of the provided value, an exception is thrown. ``` abstract fun callBy(args: Map<KParameter, Any?>): R ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty](../-k-mutable-property/index) Represents a property declared as a `var`. ``` interface KMutableProperty<V> : KProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty0](../-k-property0/index) Represents a property without any kind of receiver. Such property is either originally declared in a receiverless context such as a package, or has the receiver bound to it. ``` interface KProperty0<out V> : KProperty<V>, () -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty1](../-k-property1/index) Represents a property, operations on which take one receiver as a parameter. ``` interface KProperty1<T, out V> : KProperty<V>, (T) -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty2](../-k-property2/index) Represents a property, operations on which take two receivers as parameters, such as an extension property declared in a class. ``` interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V ```
programming_docs
kotlin isLateinit isLateinit ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty](index) / [isLateinit](is-lateinit) **Platform and version requirements:** JVM (1.1) ``` abstract val isLateinit: Boolean ``` `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. kotlin isConst isConst ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty](index) / [isConst](is-const) **Platform and version requirements:** JVM (1.1) ``` abstract val isConst: Boolean ``` `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. kotlin Getter Getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty](index) / [Getter](-getter) **Platform and version requirements:** JVM (1.0) ``` interface Getter<out V> : KProperty.Accessor<V>, KFunction<V> ``` Getter of the property is a `get` method declared alongside the property. Inherited Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [isExternal](../-k-function/is-external) `true` if this function is `external`. See the [Kotlin language documentation](../../../../../../docs/java-interop#using-jni-with-kotlin) for more information. ``` abstract val isExternal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInfix](../-k-function/is-infix) `true` if this function is `infix`. See the [Kotlin language documentation](../../../../../../docs/functions#infix-notation) for more information. ``` abstract val isInfix: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInline](../-k-function/is-inline) `true` if this function is `inline`. See the [Kotlin language documentation](../../../../../../docs/inline-functions) for more information. ``` abstract val isInline: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOperator](../-k-function/is-operator) `true` if this function is `operator`. See the [Kotlin language documentation](../../../../../../docs/operator-overloading) for more information. ``` abstract val isOperator: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSuspend](../-k-function/is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [Getter](../-k-property0/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Getter<V>, () -> V ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../-k-property1/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<T, out V> : KProperty.Getter<V>, (T) -> V ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../-k-property2/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<D, E, out V> :      KProperty.Getter<V>,     (D, E) -> V ``` kotlin Accessor Accessor ======== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KProperty](../index) / [Accessor](index) **Platform and version requirements:** JVM (1.0) ``` interface Accessor<out V> ``` Represents a property accessor, which is a `get` or `set` method declared alongside the property. See the [Kotlin language documentation](../../../../../../../docs/properties#getters-and-setters) for more information. Parameters ---------- `V` - the type of the property, which it is an accessor of. Properties ---------- **Platform and version requirements:** JVM (1.0) #### <property> The property which this accessor is originated from. ``` abstract val property: KProperty<V> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [Getter](../-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Accessor<V>, KFunction<V> ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../../-k-mutable-property/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit> ``` kotlin property property ======== [kotlin-stdlib](../../../../../../../index) / [kotlin.reflect](../../index) / [KProperty](../index) / [Accessor](index) / <property> **Platform and version requirements:** JVM (1.0) ``` abstract val property: KProperty<V> ``` The property which this accessor is originated from. kotlin INVARIANT INVARIANT ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVariance](index) / [INVARIANT](-i-n-v-a-r-i-a-n-t) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` INVARIANT ``` The affected type parameter or type is *invariant*, which means it has no variance applied to it. kotlin KVariance KVariance ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVariance](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` enum class KVariance ``` Represents variance applied to a type parameter on the declaration site (*declaration-site variance*), or to a type in a projection (*use-site variance*). See the [Kotlin language documentation](../../../../../../docs/generics#variance) for more information. **See Also** [KTypeParameter.variance](../-k-type-parameter/variance) [KTypeProjection](../-k-type-projection/index) Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [INVARIANT](-i-n-v-a-r-i-a-n-t) The affected type parameter or type is *invariant*, which means it has no variance applied to it. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IN](-i-n) The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [OUT](-o-u-t) The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code. 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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](../../kotlin/compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other) object, a negative number if it's less than [other](../../kotlin/compare-to#kotlin%24compareTo(kotlin.Comparable((kotlin.compareTo.T)),%20kotlin.compareTo.T)/other), or a positive number if it's greater than [other](../../kotlin/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:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [Comparable](../../kotlin/-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](../../kotlin/-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> ``` kotlin IN IN == [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVariance](index) / [IN](-i-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` IN ``` The affected type parameter or type is *contravariant*. Denoted by the `in` modifier in the source code. kotlin OUT OUT === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVariance](index) / [OUT](-o-u-t) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` OUT ``` The affected type parameter or type is *covariant*. Denoted by the `out` modifier in the source code. kotlin KMutableProperty1 KMutableProperty1 ================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty1](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KMutableProperty1<T, V> :      KProperty1<T, V>,     KMutableProperty<V> ``` Represents a `var`-property, operations on which take one receiver as a parameter. Types ----- **Platform and version requirements:** JVM (1.0) #### [Setter](-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<T, V> :      KMutableProperty.Setter<V>,     (T, V) -> Unit ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <setter> The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty1.Setter<T, V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property1/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty1.Getter<T, V> ``` **Platform and version requirements:** JVM (1.0) #### [setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty.Setter<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Modifies the value of the property. ``` abstract fun set(receiver: T, value: V) ``` Inherited Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [getDelegate](../-k-property1/get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(receiver: T): Any? ``` **Platform and version requirements:** Native (1.3) #### [invoke](../-k-property1/invoke) ``` abstract operator fun invoke(p1: T): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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) #### [javaSetter](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [getValue](../../kotlin/get-value) An extension operator that allows delegating a read-only member or extension property of type [V](../../kotlin/get-value#V) to a property reference to a member or extension property of type [V](../../kotlin/get-value#V) or its subtype. ``` operator fun <T, V> KProperty1<T, V>.getValue(     thisRef: T,     property: KProperty<*> ): V ``` **Platform and version requirements:** JVM (1.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [setValue](../../kotlin/set-value) An extension operator that allows delegating a mutable member or extension property of type [V](../../kotlin/set-value#V) to a property reference to a member or extension mutable property of the same type [V](../../kotlin/set-value#V). ``` operator fun <T, V> KMutableProperty1<T, V>.setValue(     thisRef: T,     property: KProperty<*>,     value: V) ``` kotlin setter setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty1](index) / <setter> **Platform and version requirements:** JVM (1.0) ``` abstract val setter: KMutableProperty1.Setter<T, V> ``` Overrides [KMutableProperty.setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. kotlin Setter Setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty1](index) / [Setter](-setter) **Platform and version requirements:** JVM (1.0) ``` interface Setter<T, V> :      KMutableProperty.Setter<V>,     (T, V) -> Unit ``` Setter of the property is a `set` method declared alongside the property. Can be used as a function that takes the receiver and the new property value as arguments and returns [Unit](../../kotlin/-unit/index#kotlin.Unit).
programming_docs
kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty1](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun set(receiver: T, value: V) ``` Modifies the value of the property. Parameters ---------- `receiver` - the receiver which is used to modify the value of the property. For example, it should be a class instance if this is a member property of that class, or an extension receiver if this is a top level extension property. `value` - the new value to be assigned to this property. kotlin isFinal isFinal ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isFinal](is-final) **Platform and version requirements:** JVM (1.1) ``` abstract val isFinal: Boolean ``` `true` if this class is `final`. kotlin isCompanion isCompanion =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isCompanion](is-companion) **Platform and version requirements:** JVM (1.1) ``` abstract val isCompanion: Boolean ``` `true` if this class is a companion object. See the [Kotlin language documentation](../../../../../../docs/object-declarations#companion-objects) for more information. kotlin isInner isInner ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isInner](is-inner) **Platform and version requirements:** JVM (1.1) ``` abstract val isInner: Boolean ``` `true` if this class is an inner class. See the [Kotlin language documentation](../../../../../../docs/nested-classes#inner-classes) for more information. kotlin isFun isFun ===== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isFun](is-fun) **Platform and version requirements:** JVM (1.4) ``` abstract val isFun: Boolean ``` `true` if this class is a Kotlin functional interface. kotlin KClass KClass ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ``` Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../../docs/reflection#class-references) for more information. Parameters ---------- `T` - the type of the class. Properties ---------- **Platform and version requirements:** JVM (1.0) #### <constructors> All constructors declared in this class. ``` abstract val constructors: Collection<KFunction<T>> ``` **Platform and version requirements:** JVM (1.1) #### [isAbstract](is-abstract) `true` if this class is `abstract`. ``` abstract val isAbstract: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isCompanion](is-companion) `true` if this class is a companion object. See the [Kotlin language documentation](../../../../../../docs/object-declarations#companion-objects) for more information. ``` abstract val isCompanion: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isData](is-data) `true` if this class is a data class. See the [Kotlin language documentation](../../../../../../docs/data-classes) for more information. ``` abstract val isData: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isFinal](is-final) `true` if this class is `final`. ``` abstract val isFinal: Boolean ``` **Platform and version requirements:** JVM (1.4) #### [isFun](is-fun) `true` if this class is a Kotlin functional interface. ``` abstract val isFun: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInner](is-inner) `true` if this class is an inner class. See the [Kotlin language documentation](../../../../../../docs/nested-classes#inner-classes) for more information. ``` abstract val isInner: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOpen](is-open) `true` if this class is `open`. ``` abstract val isOpen: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSealed](is-sealed) `true` if this class is `sealed`. See the [Kotlin language documentation](../../../../../../docs/sealed-classes) for more information. ``` abstract val isSealed: Boolean ``` **Platform and version requirements:** JVM (1.5) #### [isValue](is-value) `true` if this class is a value class. ``` abstract val isValue: Boolean ``` **Platform and version requirements:** JVM (1.0) #### <members> All functions and properties accessible in this class, including those declared in this class and all of its superclasses. Does not include constructors. ``` abstract val members: Collection<KCallable<*>> ``` **Platform and version requirements:** JVM (1.0) #### [nestedClasses](nested-classes) All classes declared inside this class. This includes both inner and static nested classes. ``` abstract val nestedClasses: Collection<KClass<*>> ``` **Platform and version requirements:** JVM (1.0) #### [objectInstance](object-instance) The instance of the object declaration, or `null` if this class is not an object declaration. ``` abstract val objectInstance: T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [qualifiedName](qualified-name) The fully qualified dot-separated name of the class, or `null` if the class is local or a class of an anonymous object. ``` abstract val qualifiedName: String? ``` **Platform and version requirements:** JVM (1.3) #### [sealedSubclasses](sealed-subclasses) The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise. ``` abstract val sealedSubclasses: List<KClass<out T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [simpleName](simple-name) The simple name of the class as it was declared in the source code, or `null` if the class has no name (if, for example, it is a class of an anonymous object). ``` abstract val simpleName: String? ``` **Platform and version requirements:** JVM (1.1) #### <supertypes> The list of immediate supertypes of this class, in the order they are listed in the source code. ``` abstract val supertypes: List<KType> ``` **Platform and version requirements:** JVM (1.1) #### [typeParameters](type-parameters) The list of type parameters of this class. This list does *not* include type parameters of outer classes. ``` abstract val typeParameters: List<KTypeParameter> ``` **Platform and version requirements:** JVM (1.1) #### <visibility> Visibility of this class, or `null` if its visibility cannot be represented in Kotlin. ``` abstract val visibility: KVisibility? ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotations](../-k-annotated-element/annotations) Annotations which are present on this element. ``` abstract val annotations: List<Annotation> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Returns `true` if this [KClass](index#kotlin.reflect.KClass) instance represents the same Kotlin class as the class represented by [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other). On JVM this means that all of the following conditions are satisfied: ``` abstract fun equals(other: Any?): Boolean ``` **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: ``` abstract fun hashCode(): Int ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [isInstance](is-instance) Returns `true` if [value](is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)/value) is an instance of this class on a given platform. ``` abstract fun isInstance(value: Any?): Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [allSuperclasses](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/companion-object) Returns a [KClass](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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/declared-member-extension-functions) Returns extension functions declared in this class. ``` val KClass<*>.declaredMemberExtensionFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [declaredMemberExtensionProperties](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/default-type) would return the type `MyMap<K, V>`. ``` val KClass<*>.defaultType: KType ``` **Platform and version requirements:** JVM (1.1) #### [functions](../../kotlin.reflect.full/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.0) #### [java](../../kotlin.jvm/java) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance corresponding to the given [KClass](index#kotlin.reflect.KClass) instance. ``` val <T> KClass<T>.java: Class<T> ``` **Platform and version requirements:** JVM (1.0) #### [javaClass](../../kotlin.jvm/java-class) ``` val <T : Any> KClass<T>.javaClass: Class<KClass<T>> ``` **Platform and version requirements:** JVM (1.0) #### [javaObjectType](../../kotlin.jvm/java-object-type) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance corresponding to the given [KClass](index#kotlin.reflect.KClass) instance. In case of primitive types it returns corresponding wrapper classes. ``` val <T : Any> KClass<T>.javaObjectType: Class<T> ``` **Platform and version requirements:** JVM (1.0) #### [javaPrimitiveType](../../kotlin.jvm/java-primitive-type) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance representing the primitive type corresponding to the given [KClass](index#kotlin.reflect.KClass) if it exists. ``` val <T : Any> KClass<T>.javaPrimitiveType: Class<T>? ``` **Platform and version requirements:** JS (1.1) #### [js](../../kotlin.js/js) Obtains a constructor reference for the given `KClass`. ``` val <T : Any> KClass<T>.js: JsClass<T> ``` **Platform and version requirements:** JVM (1.0) #### [jvmName](../../kotlin.reflect.jvm/jvm-name) Returns the JVM name of the class represented by this [KClass](index#kotlin.reflect.KClass) instance. ``` val KClass<*>.jvmName: String ``` **Platform and version requirements:** JVM (1.1) #### [memberExtensionFunctions](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/star-projected-type) Creates an instance of [KType](../-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](../../kotlin.reflect.full/static-functions) Returns static functions declared in this class. ``` val KClass<*>.staticFunctions: Collection<KFunction<*>> ``` **Platform and version requirements:** JVM (1.1) #### [staticProperties](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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<*>> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [cast](../cast) Casts the given [value](../cast#kotlin.reflect%24cast(kotlin.reflect.KClass((kotlin.reflect.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](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) #### [cast](../../kotlin.reflect.full/cast) Casts the given [value](../../kotlin.reflect.full/cast#kotlin.reflect.full%24cast(kotlin.reflect.KClass((kotlin.reflect.full.cast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](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](../../kotlin.reflect.full/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](../-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](../../kotlin.reflect.full/create-type) Creates a [KType](../-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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSubclassOf](../../kotlin.reflect.full/is-subclass-of) Returns `true` if `this` class is the same or is a (possibly indirect) subclass of [base](../../kotlin.reflect.full/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) #### [isSuperclassOf](../../kotlin.reflect.full/is-superclass-of) Returns `true` if `this` class is the same or is a (possibly indirect) superclass of [derived](../../kotlin.reflect.full/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.4), JS (1.4), Native (1.4) #### [safeCast](../safe-cast) Casts the given [value](../safe-cast#kotlin.reflect%24safeCast(kotlin.reflect.KClass((kotlin.reflect.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](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) #### [safeCast](../../kotlin.reflect.full/safe-cast) Casts the given [value](../../kotlin.reflect.full/safe-cast#kotlin.reflect.full%24safeCast(kotlin.reflect.KClass((kotlin.reflect.full.safeCast.T)),%20kotlin.Any?)/value) to the class represented by this [KClass](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? ```
programming_docs
kotlin simpleName simpleName ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [simpleName](simple-name) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract val simpleName: String? ``` The simple name of the class as it was declared in the source code, or `null` if the class has no name (if, for example, it is a class of an anonymous object). kotlin nestedClasses nestedClasses ============= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [nestedClasses](nested-classes) **Platform and version requirements:** JVM (1.0) ``` abstract val nestedClasses: Collection<KClass<*>> ``` All classes declared inside this class. This includes both inner and static nested classes. kotlin sealedSubclasses sealedSubclasses ================ [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [sealedSubclasses](sealed-subclasses) **Platform and version requirements:** JVM (1.3) ``` abstract val sealedSubclasses: List<KClass<out T>> ``` The list of the immediate subclasses if this class is a sealed class, or an empty list otherwise. kotlin visibility visibility ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / <visibility> **Platform and version requirements:** JVM (1.1) ``` abstract val visibility: KVisibility? ``` Visibility of this class, or `null` if its visibility cannot be represented in Kotlin. kotlin isAbstract isAbstract ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isAbstract](is-abstract) **Platform and version requirements:** JVM (1.1) ``` abstract val isAbstract: Boolean ``` `true` if this class is `abstract`. kotlin objectInstance objectInstance ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [objectInstance](object-instance) **Platform and version requirements:** JVM (1.0) ``` abstract val objectInstance: T? ``` The instance of the object declaration, or `null` if this class is not an object declaration. kotlin isData isData ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isData](is-data) **Platform and version requirements:** JVM (1.1) ``` abstract val isData: Boolean ``` `true` if this class is a data class. See the [Kotlin language documentation](../../../../../../docs/data-classes) for more information. kotlin typeParameters typeParameters ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [typeParameters](type-parameters) **Platform and version requirements:** JVM (1.1) ``` abstract val typeParameters: List<KTypeParameter> ``` The list of type parameters of this class. This list does *not* include type parameters of outer classes. kotlin members members ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / <members> **Platform and version requirements:** JVM (1.0) ``` abstract val members: Collection<KCallable<*>> ``` Overrides [KDeclarationContainer.members](../-k-declaration-container/members) All functions and properties accessible in this class, including those declared in this class and all of its superclasses. Does not include constructors. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract 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 equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun equals(other: Any?): Boolean ``` ##### For JVM Returns `true` if this [KClass](index#kotlin.reflect.KClass) instance represents the same Kotlin class as the class represented by [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other). On JVM this means that all of the following conditions are satisfied: 1. [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other) has the same (fully qualified) Kotlin class name as this instance. 2. [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other)'s backing [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) object is loaded with the same class loader as the [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) object of this instance. 3. If the classes represent [Array](../../kotlin/-array/index#kotlin.Array), then [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) objects of their element types are equal. For example, on JVM, [KClass](index#kotlin.reflect.KClass) instances for a primitive type (`int`) and the corresponding wrapper type (`java.lang.Integer`) are considered equal, because they have the same fully qualified name "kotlin.Int". ##### For JS, Native Returns `true` if this [KClass](index#kotlin.reflect.KClass) instance represents the same Kotlin class as the class represented by [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other). On JVM this means that all of the following conditions are satisfied: 1. [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other) has the same (fully qualified) Kotlin class name as this instance. 2. [other](equals#kotlin.reflect.KClass%24equals(kotlin.Any?)/other)'s backing Class object is loaded with the same class loader as the Class object of this instance. 3. If the classes represent Array, then Class objects of their element types are equal. For example, on JVM, [KClass](index#kotlin.reflect.KClass) instances for a primitive type (`int`) and the corresponding wrapper type (`java.lang.Integer`) are considered equal, because they have the same fully qualified name "kotlin.Int". kotlin qualifiedName qualifiedName ============= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [qualifiedName](qualified-name) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract val qualifiedName: String? ``` ##### For Common, JVM, Native The fully qualified dot-separated name of the class, or `null` if the class is local or a class of an anonymous object. ##### For JS The fully qualified dot-separated name of the class, or `null` if the class is local or a class of an anonymous object. This property is currently not supported in Kotlin/JS. kotlin isSealed isSealed ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isSealed](is-sealed) **Platform and version requirements:** JVM (1.1) ``` abstract val isSealed: Boolean ``` `true` if this class is `sealed`. See the [Kotlin language documentation](../../../../../../docs/sealed-classes) for more information. kotlin isOpen isOpen ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isOpen](is-open) **Platform and version requirements:** JVM (1.1) ``` abstract val isOpen: Boolean ``` `true` if this class is `open`. kotlin constructors constructors ============ [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / <constructors> **Platform and version requirements:** JVM (1.0) ``` abstract val constructors: Collection<KFunction<T>> ``` All constructors declared in this class. kotlin supertypes supertypes ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / <supertypes> **Platform and version requirements:** JVM (1.1) ``` abstract val supertypes: List<KType> ``` The list of immediate supertypes of this class, in the order they are listed in the source code. kotlin isInstance isInstance ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isInstance](is-instance) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` abstract fun isInstance(value: Any?): Boolean ``` Returns `true` if [value](is-instance#kotlin.reflect.KClass%24isInstance(kotlin.Any?)/value) is an instance of this class on a given platform. kotlin isValue isValue ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KClass](index) / [isValue](is-value) **Platform and version requirements:** JVM (1.5) ``` abstract val isValue: Boolean ``` `true` if this class is a value class. kotlin KMutableProperty0 KMutableProperty0 ================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty0](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KMutableProperty0<V> :      KProperty0<V>,     KMutableProperty<V> ``` Represents a `var`-property without any kind of receiver. Types ----- **Platform and version requirements:** JVM (1.0) #### [Setter](-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KMutableProperty.Setter<V>, (V) -> Unit ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <setter> The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty0.Setter<V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property0/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty0.Getter<V> ``` **Platform and version requirements:** JVM (1.0) #### [setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty.Setter<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Modifies the value of the property. ``` abstract fun set(value: V) ``` Inherited Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [getDelegate](../-k-property0/get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(): Any? ``` **Platform and version requirements:** Native (1.3) #### [invoke](../-k-property0/invoke) ``` abstract operator fun invoke(): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [isInitialized](../../kotlin/is-initialized) Returns `true` if this lateinit property has been assigned a value, and `false` otherwise. ``` val KProperty0<*>.isInitialized: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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) #### [javaSetter](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4), JS (1.4), Native (1.4) #### [getValue](../../kotlin/get-value) An extension operator that allows delegating a read-only property of type [V](../../kotlin/get-value#V) to a property reference to a property of type [V](../../kotlin/get-value#V) or its subtype. ``` operator fun <V> KProperty0<V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V ``` **Platform and version requirements:** JVM (1.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [setValue](../../kotlin/set-value) An extension operator that allows delegating a mutable property of type [V](../../kotlin/set-value#V) to a property reference to a mutable property of the same type [V](../../kotlin/set-value#V). ``` operator fun <V> KMutableProperty0<V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` kotlin setter setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty0](index) / <setter> **Platform and version requirements:** JVM (1.0) ``` abstract val setter: KMutableProperty0.Setter<V> ``` Overrides [KMutableProperty.setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. kotlin Setter Setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty0](index) / [Setter](-setter) **Platform and version requirements:** JVM (1.0) ``` interface Setter<V> : KMutableProperty.Setter<V>, (V) -> Unit ``` Setter of the property is a `set` method declared alongside the property. Can be used as a function that takes new property value as an argument and returns [Unit](../../kotlin/-unit/index#kotlin.Unit). kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty0](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun set(value: V) ``` Modifies the value of the property. Parameters ---------- `value` - the new value to be assigned to this property. kotlin KDeclarationContainer KDeclarationContainer ===================== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KDeclarationContainer](index) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KDeclarationContainer ``` Represents an entity which may contain declarations of any other entities, such as a class or a package. Properties ---------- **Platform and version requirements:** JVM (1.0) #### <members> All functions and properties accessible in this container. ``` abstract val members: Collection<KCallable<*>> ``` Inheritors ---------- #### [KClass](../-k-class/index) Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../../docs/reflection#class-references) for more information. **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ```
programming_docs
kotlin members members ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KDeclarationContainer](index) / <members> **Platform and version requirements:** JVM (1.0) ``` abstract val members: Collection<KCallable<*>> ``` All functions and properties accessible in this container. kotlin ExperimentalAssociatedObjects ExperimentalAssociatedObjects ============================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [ExperimentalAssociatedObjects](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` annotation class ExperimentalAssociatedObjects ``` The experimental marker for associated objects API. Any usage of a declaration annotated with `@ExperimentalAssociatedObjects` must be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalAssociatedObjects::class)`, or by using the compiler argument `-opt-in=kotlin.reflect.ExperimentalAssociatedObjects`. Constructors ------------ **Platform and version requirements:** JS (1.1), Native (1.1) #### [<init>](-init-) The experimental marker for associated objects API. ``` <init>() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [ExperimentalAssociatedObjects](index) / [<init>](-init-) **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>() ``` The experimental marker for associated objects API. Any usage of a declaration annotated with `@ExperimentalAssociatedObjects` must be accepted either by annotating that usage with the OptIn annotation, e.g. `@OptIn(ExperimentalAssociatedObjects::class)`, or by using the compiler argument `-opt-in=kotlin.reflect.ExperimentalAssociatedObjects`. kotlin returnType returnType ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [returnType](return-type) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` abstract val returnType: KType ``` The type of values returned by this callable. kotlin isFinal isFinal ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [isFinal](is-final) **Platform and version requirements:** JVM (1.1) ``` abstract val isFinal: Boolean ``` `true` if this callable is `final`. kotlin KCallable KCallable ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) **Platform and version requirements:** JS (1.1) ``` interface KCallable<out R> ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KCallable<out R> : KAnnotatedElement ``` Represents a callable entity, such as a function or a property. Parameters ---------- `R` - return type of the callable. Properties ---------- **Platform and version requirements:** JVM (1.1) #### [isAbstract](is-abstract) `true` if this callable is `abstract`. ``` abstract val isAbstract: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isFinal](is-final) `true` if this callable is `final`. ``` abstract val isFinal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOpen](is-open) `true` if this callable is `open`. ``` abstract val isOpen: Boolean ``` **Platform and version requirements:** JVM (1.3) #### [isSuspend](is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <name> The name of this callable as it was declared in the source code. If the callable has no name, a special invented name is created. Nameless callables include: ``` abstract val name: String ``` **Platform and version requirements:** JVM (1.0) #### <parameters> Parameters required to make a call to this callable. If this callable requires a `this` instance or an extension receiver parameter, they come first in the list in that order. ``` abstract val parameters: List<KParameter> ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [returnType](return-type) The type of values returned by this callable. ``` abstract val returnType: KType ``` **Platform and version requirements:** JVM (1.1) #### [typeParameters](type-parameters) The list of type parameters of this callable. ``` abstract val typeParameters: List<KTypeParameter> ``` **Platform and version requirements:** JVM (1.1) #### <visibility> Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin. ``` abstract val visibility: KVisibility? ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [annotations](../-k-annotated-element/annotations) Annotations which are present on this element. ``` abstract val annotations: List<Annotation> ``` Functions --------- **Platform and version requirements:** JVM (1.0) #### <call> Calls this callable with the specified list of arguments and returns the result. Throws an exception if the number of specified arguments is not equal to the size of <parameters>, or if their types do not match the types of the parameters. ``` abstract fun call(vararg args: Any?): R ``` **Platform and version requirements:** JVM (1.0) #### [callBy](call-by) Calls this callable with the specified mapping of parameters to arguments and returns the result. If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional](../-k-parameter/is-optional)), or its type does not match the type of the provided value, an exception is thrown. ``` abstract fun callBy(args: Map<KParameter, Any?>): R ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KFunction](../-k-function/index) Represents a function with introspection capabilities. ``` interface KFunction<out R> : KCallable<R>, Function<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty](../-k-property/index) Represents a property, such as a named `val` or `var` declaration. Instances of this class are obtainable by the `::` operator. ``` interface KProperty<out V> : KCallable<V> ``` kotlin visibility visibility ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / <visibility> **Platform and version requirements:** JVM (1.1) ``` abstract val visibility: KVisibility? ``` Visibility of this callable, or `null` if its visibility cannot be represented in Kotlin. kotlin isAbstract isAbstract ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [isAbstract](is-abstract) **Platform and version requirements:** JVM (1.1) ``` abstract val isAbstract: Boolean ``` `true` if this callable is `abstract`. kotlin typeParameters typeParameters ============== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [typeParameters](type-parameters) **Platform and version requirements:** JVM (1.1) ``` abstract val typeParameters: List<KTypeParameter> ``` The list of type parameters of this callable. kotlin call call ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / <call> **Platform and version requirements:** JVM (1.0) ``` abstract fun call(vararg args: Any?): R ``` Calls this callable with the specified list of arguments and returns the result. Throws an exception if the number of specified arguments is not equal to the size of <parameters>, or if their types do not match the types of the parameters. kotlin isSuspend isSuspend ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [isSuspend](is-suspend) **Platform and version requirements:** JVM (1.3) ``` abstract val isSuspend: Boolean ``` `true` if this is a suspending function. kotlin callBy callBy ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [callBy](call-by) **Platform and version requirements:** JVM (1.0) ``` abstract fun callBy(args: Map<KParameter, Any?>): R ``` Calls this callable with the specified mapping of parameters to arguments and returns the result. If a parameter is not found in the mapping and is not optional (as per [KParameter.isOptional](../-k-parameter/is-optional)), or its type does not match the type of the provided value, an exception is thrown. kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / <name> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract val name: String ``` The name of this callable as it was declared in the source code. If the callable has no name, a special invented name is created. Nameless callables include: * constructors have the name "", * property accessors: the getter for a property named "foo" will have the name "<get-foo>", the setter, similarly, will have the name "<set-foo>". kotlin isOpen isOpen ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / [isOpen](is-open) **Platform and version requirements:** JVM (1.1) ``` abstract val isOpen: Boolean ``` `true` if this callable is `open`. kotlin parameters parameters ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KCallable](index) / <parameters> **Platform and version requirements:** JVM (1.0) ``` abstract val parameters: List<KParameter> ``` Parameters required to make a call to this callable. If this callable requires a `this` instance or an extension receiver parameter, they come first in the list in that order. kotlin getter getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) / <getter> **Platform and version requirements:** JVM (1.0) ``` abstract val getter: KProperty0.Getter<V> ``` Overrides [KProperty.getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. kotlin KProperty0 KProperty0 ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KProperty0<out V> : KProperty<V>, () -> V ``` Represents a property without any kind of receiver. Such property is either originally declared in a receiverless context such as a package, or has the receiver bound to it. Types ----- **Platform and version requirements:** JVM (1.0) #### [Getter](-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Getter<V>, () -> V ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <getter> The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty0.Getter<V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty.Getter<V> ``` **Platform and version requirements:** JVM (1.1) #### [isConst](../-k-property/is-const) `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. ``` abstract val isConst: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isLateinit](../-k-property/is-lateinit) `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. ``` abstract val isLateinit: Boolean ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the current value of the property. ``` abstract fun get(): V ``` **Platform and version requirements:** JVM (1.1) #### [getDelegate](get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(): Any? ``` **Platform and version requirements:** Native (1.3) #### <invoke> ``` abstract operator fun invoke(): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [isInitialized](../../kotlin/is-initialized) Returns `true` if this lateinit property has been assigned a value, and `false` otherwise. ``` val KProperty0<*>.isInitialized: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4), JS (1.4), Native (1.4) #### [getValue](../../kotlin/get-value) An extension operator that allows delegating a read-only property of type [V](../../kotlin/get-value#V) to a property reference to a property of type [V](../../kotlin/get-value#V) or its subtype. ``` operator fun <V> KProperty0<V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V ``` **Platform and version requirements:** JVM (1.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty0](../-k-mutable-property0/index) Represents a `var`-property without any kind of receiver. ``` interface KMutableProperty0<V> :      KProperty0<V>,     KMutableProperty<V> ```
programming_docs
kotlin invoke invoke ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) / <invoke> **Platform and version requirements:** Native (1.3) ``` abstract operator fun invoke(): V ``` kotlin getDelegate getDelegate =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) / [getDelegate](get-delegate) **Platform and version requirements:** JVM (1.1) ``` abstract fun getDelegate(): Any? ``` Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. kotlin Getter Getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) / [Getter](-getter) **Platform and version requirements:** JVM (1.0) ``` interface Getter<out V> : KProperty.Getter<V>, () -> V ``` Getter of the property is a `get` method declared alongside the property. Can be used as a function that takes 0 arguments and returns the value of the property type [V](-getter#V). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty0](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun get(): V ``` Returns the current value of the property. kotlin PRIVATE PRIVATE ======= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVisibility](index) / [PRIVATE](-p-r-i-v-a-t-e) **Platform and version requirements:** JVM (1.0) ``` PRIVATE ``` Visibility of declarations marked with the `private` modifier. kotlin INTERNAL INTERNAL ======== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVisibility](index) / [INTERNAL](-i-n-t-e-r-n-a-l) **Platform and version requirements:** JVM (1.0) ``` INTERNAL ``` Visibility of declarations marked with the `internal` modifier. kotlin KVisibility KVisibility =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVisibility](index) **Platform and version requirements:** JVM (1.1) ``` enum class KVisibility ``` Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code. Visibility can be changed with one of the following modifiers: `public`, `protected`, `internal`, `private`. Note that some Java visibilities such as package-private and protected (which also gives access to items from the same package) cannot be represented in Kotlin, so there's no [KVisibility](index) value corresponding to them. See the [Kotlin language documentation](../../../../../../docs/visibility-modifiers) for more information. Enum Values ----------- **Platform and version requirements:** JVM (1.0) #### [PUBLIC](-p-u-b-l-i-c) Visibility of declarations marked with the `public` modifier, or with no modifier at all. **Platform and version requirements:** JVM (1.0) #### [PROTECTED](-p-r-o-t-e-c-t-e-d) Visibility of declarations marked with the `protected` modifier. **Platform and version requirements:** JVM (1.0) #### [INTERNAL](-i-n-t-e-r-n-a-l) Visibility of declarations marked with the `internal` modifier. **Platform and version requirements:** JVM (1.0) #### [PRIVATE](-p-r-i-v-a-t-e) Visibility of declarations marked with the `private` modifier. Extension Properties -------------------- **Platform and version requirements:** JVM (1.7) #### [declaringJavaClass](../../kotlin.jvm/declaring-java-class) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance of the enum the given constant belongs to. ``` val <E : Enum<E>> Enum<E>.declaringJavaClass: Class<E> ``` kotlin PROTECTED PROTECTED ========= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVisibility](index) / [PROTECTED](-p-r-o-t-e-c-t-e-d) **Platform and version requirements:** JVM (1.0) ``` PROTECTED ``` Visibility of declarations marked with the `protected` modifier. kotlin PUBLIC PUBLIC ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KVisibility](index) / [PUBLIC](-p-u-b-l-i-c) **Platform and version requirements:** JVM (1.0) ``` PUBLIC ``` Visibility of declarations marked with the `public` modifier, or with no modifier at all. kotlin getter getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) / <getter> **Platform and version requirements:** JVM (1.0) ``` abstract val getter: KProperty1.Getter<T, V> ``` Overrides [KProperty.getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. kotlin KProperty1 KProperty1 ========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KProperty1<T, out V> : KProperty<V>, (T) -> V ``` Represents a property, operations on which take one receiver as a parameter. Parameters ---------- `T` - the type of the receiver which should be used to obtain the value of the property. `V` - the type of the property value. Types ----- **Platform and version requirements:** JVM (1.0) #### [Getter](-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<T, out V> : KProperty.Getter<V>, (T) -> V ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <getter> The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty1.Getter<T, V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty.Getter<V> ``` **Platform and version requirements:** JVM (1.1) #### [isConst](../-k-property/is-const) `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. ``` abstract val isConst: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isLateinit](../-k-property/is-lateinit) `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. ``` abstract val isLateinit: Boolean ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the current value of the property. ``` abstract fun get(receiver: T): V ``` **Platform and version requirements:** JVM (1.1) #### [getDelegate](get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(receiver: T): Any? ``` **Platform and version requirements:** Native (1.3) #### <invoke> ``` abstract operator fun invoke(p1: T): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [getValue](../../kotlin/get-value) An extension operator that allows delegating a read-only member or extension property of type [V](../../kotlin/get-value#V) to a property reference to a member or extension property of type [V](../../kotlin/get-value#V) or its subtype. ``` operator fun <T, V> KProperty1<T, V>.getValue(     thisRef: T,     property: KProperty<*> ): V ``` **Platform and version requirements:** JVM (1.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty1](../-k-mutable-property1/index) Represents a `var`-property, operations on which take one receiver as a parameter. ``` interface KMutableProperty1<T, V> :      KProperty1<T, V>,     KMutableProperty<V> ``` kotlin invoke invoke ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) / <invoke> **Platform and version requirements:** Native (1.3) ``` abstract operator fun invoke(p1: T): V ``` kotlin getDelegate getDelegate =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) / [getDelegate](get-delegate) **Platform and version requirements:** JVM (1.1) ``` abstract fun getDelegate(receiver: T): Any? ``` Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. Note that for a top level **extension** property, the delegate is the same for all extension receivers, so the actual [receiver](get-delegate#kotlin.reflect.KProperty1%24getDelegate(kotlin.reflect.KProperty1.T)/receiver) instance passed in is not going to make any difference, it must only be a value of [T](index#T). Parameters ---------- `receiver` - the receiver which is used to obtain the value of the property delegate. For example, it should be a class instance if this is a member property of that class, or an extension receiver if this is a top level extension property. **See Also** [kotlin.reflect.full.getExtensionDelegate](../../kotlin.reflect.full/get-extension-delegate) kotlin Getter Getter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) / [Getter](-getter) **Platform and version requirements:** JVM (1.0) ``` interface Getter<T, out V> : KProperty.Getter<V>, (T) -> V ``` Getter of the property is a `get` method declared alongside the property. Can be used as a function that takes an argument of type [T](-getter#T) (the receiver) and returns the value of the property type [V](-getter#V). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KProperty1](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun get(receiver: T): V ``` Returns the current value of the property. Parameters ---------- `receiver` - the receiver which is used to obtain the value of the property. For example, it should be a class instance if this is a member property of that class, or an extension receiver if this is a top level extension property. kotlin annotations annotations =========== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KAnnotatedElement](index) / <annotations> **Platform and version requirements:** JVM (1.0) ``` abstract val annotations: List<Annotation> ``` Annotations which are present on this element. kotlin KAnnotatedElement KAnnotatedElement ================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KAnnotatedElement](index) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KAnnotatedElement ``` Represents an annotated element and allows to obtain its annotations. See the [Kotlin language documentation](../../../../../../docs/annotations) for more information. Properties ---------- **Platform and version requirements:** JVM (1.0) #### <annotations> Annotations which are present on this element. ``` abstract val annotations: List<Annotation> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` Inheritors ---------- #### [KCallable](../-k-callable/index) Represents a callable entity, such as a function or a property. **Platform and version requirements:** JS (1.1) ``` interface KCallable<out R> ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KCallable<out R> : KAnnotatedElement ``` #### [KClass](../-k-class/index) Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../../docs/reflection#class-references) for more information. **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ``` **Platform and version requirements:** JVM (1.0) #### [KParameter](../-k-parameter/index) Represents a parameter passed to a function or a property getter/setter, including `this` and extension receiver parameters. ``` interface KParameter : KAnnotatedElement ``` #### [KType](../-k-type/index) Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability. **Platform and version requirements:** JS (1.1), Native (1.3) ``` interface KType ``` **Platform and version requirements:** JVM (1.0) ``` interface KType : KAnnotatedElement ``` kotlin KMutableProperty2 KMutableProperty2 ================= [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty2](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KMutableProperty2<D, E, V> :      KProperty2<D, E, V>,     KMutableProperty<V> ``` Represents a `var`-property, operations on which take two receivers as parameters. Types ----- **Platform and version requirements:** JVM (1.0) #### [Setter](-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<D, E, V> :      KMutableProperty.Setter<V>,     (D, E, V) -> Unit ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <setter> The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty2.Setter<D, E, V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property2/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty2.Getter<D, E, V> ``` **Platform and version requirements:** JVM (1.0) #### [setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty.Setter<V> ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Modifies the value of the property. ``` abstract fun set(receiver1: D, receiver2: E, value: V) ``` Inherited Functions ------------------- **Platform and version requirements:** JVM (1.1) #### [getDelegate](../-k-property2/get-delegate) Returns the value of the delegate if this is a delegated property, or `null` if this property is not delegated. See the [Kotlin language documentation](../../../../../../docs/delegated-properties) for more information. ``` abstract fun getDelegate(receiver1: D, receiver2: E): Any? ``` **Platform and version requirements:** Native (1.3) #### [invoke](../-k-property2/invoke) ``` abstract operator fun invoke(p1: D, p2: E): V ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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) #### [javaSetter](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/get-extension-delegate) 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](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [reflect](../../kotlin.reflect.jvm/reflect) This is an experimental API. Given a class for a compiled Kotlin lambda or a function expression, returns a [KFunction](../-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>? ```
programming_docs
kotlin setter setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty2](index) / <setter> **Platform and version requirements:** JVM (1.0) ``` abstract val setter: KMutableProperty2.Setter<D, E, V> ``` Overrides [KMutableProperty.setter](../-k-mutable-property/setter) The setter of this mutable property, used to change the value of the property. kotlin Setter Setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty2](index) / [Setter](-setter) **Platform and version requirements:** JVM (1.0) ``` interface Setter<D, E, V> :      KMutableProperty.Setter<V>,     (D, E, V) -> Unit ``` Setter of the property is a `set` method declared alongside the property. Can be used as a function that takes an argument of type [D](-setter#D) (the first receiver), an argument of type [E](-setter#E) (the second receiver), and the new property value and returns [Unit](../../kotlin/-unit/index#kotlin.Unit). kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty2](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun set(receiver1: D, receiver2: E, value: V) ``` Modifies the value of the property. Parameters ---------- `receiver1` - the instance of the first receiver. `receiver2` - the instance of the second receiver. `value` - the new value to be assigned to this property. kotlin KMutableProperty KMutableProperty ================ [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface KMutableProperty<V> : KProperty<V> ``` Represents a property declared as a `var`. Types ----- **Platform and version requirements:** JVM (1.0) #### [Setter](-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit> ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### <setter> The setter of this mutable property, used to change the value of the property. ``` abstract val setter: KMutableProperty.Setter<V> ``` Inherited Properties -------------------- **Platform and version requirements:** JVM (1.0) #### [getter](../-k-property/getter) The getter of this property, used to obtain the value of the property. ``` abstract val getter: KProperty.Getter<V> ``` **Platform and version requirements:** JVM (1.1) #### [isConst](../-k-property/is-const) `true` if this property is `const`. See the [Kotlin language documentation](../../../../../../docs/properties#compile-time-constants) for more information. ``` abstract val isConst: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isLateinit](../-k-property/is-lateinit) `true` if this property is `lateinit`. See the [Kotlin language documentation](../../../../../../docs/properties#late-initialized-properties) for more information. ``` abstract val isLateinit: Boolean ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [extensionReceiverParameter](../../kotlin.reflect.full/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) #### [instanceParameter](../../kotlin.reflect.full/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.0) #### [isAccessible](../../kotlin.reflect.jvm/is-accessible) Provides a way to suppress JVM access checks for a callable. ``` var KCallable<*>.isAccessible: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaField](../../kotlin.reflect.jvm/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](../../kotlin.reflect.jvm/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) #### [javaSetter](../../kotlin.reflect.jvm/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.1) #### [valueParameters](../../kotlin.reflect.full/value-parameters) Returns parameters of this callable, excluding the `this` instance and the extension receiver parameter. ``` val KCallable<*>.valueParameters: List<KParameter> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3) #### [callSuspend](../../kotlin.reflect.full/call-suspend) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.call](../-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](../../kotlin.reflect.full/call-suspend-by) Calls a callable in the current suspend context. If the callable is not a suspend function, behaves as [KCallable.callBy](../-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) #### [findAnnotation](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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](../../kotlin.reflect.full/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.4) #### [hasAnnotation](../../kotlin.reflect.full/has-annotation) Returns true if this element is annotated with an annotation of type [T](../../kotlin.reflect.full/has-annotation#T). ``` fun <T : Annotation> KAnnotatedElement.hasAnnotation(): Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty0](../-k-mutable-property0/index) Represents a `var`-property without any kind of receiver. ``` interface KMutableProperty0<V> :      KProperty0<V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty1](../-k-mutable-property1/index) Represents a `var`-property, operations on which take one receiver as a parameter. ``` interface KMutableProperty1<T, V> :      KProperty1<T, V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty2](../-k-mutable-property2/index) Represents a `var`-property, operations on which take two receivers as parameters. ``` interface KMutableProperty2<D, E, V> :      KProperty2<D, E, V>,     KMutableProperty<V> ``` kotlin setter setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty](index) / <setter> **Platform and version requirements:** JVM (1.0) ``` abstract val setter: KMutableProperty.Setter<V> ``` The setter of this mutable property, used to change the value of the property. kotlin Setter Setter ====== [kotlin-stdlib](../../../../../../index) / [kotlin.reflect](../index) / [KMutableProperty](index) / [Setter](-setter) **Platform and version requirements:** JVM (1.0) ``` interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit> ``` Setter of the property is a `set` method declared alongside the property. Inherited Properties -------------------- **Platform and version requirements:** JVM (1.1) #### [isExternal](../-k-function/is-external) `true` if this function is `external`. See the [Kotlin language documentation](../../../../../../docs/java-interop#using-jni-with-kotlin) for more information. ``` abstract val isExternal: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInfix](../-k-function/is-infix) `true` if this function is `infix`. See the [Kotlin language documentation](../../../../../../docs/functions#infix-notation) for more information. ``` abstract val isInfix: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isInline](../-k-function/is-inline) `true` if this function is `inline`. See the [Kotlin language documentation](../../../../../../docs/inline-functions) for more information. ``` abstract val isInline: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isOperator](../-k-function/is-operator) `true` if this function is `operator`. See the [Kotlin language documentation](../../../../../../docs/operator-overloading) for more information. ``` abstract val isOperator: Boolean ``` **Platform and version requirements:** JVM (1.1) #### [isSuspend](../-k-function/is-suspend) `true` if this is a suspending function. ``` abstract val isSuspend: Boolean ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [Setter](../-k-mutable-property0/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KMutableProperty.Setter<V>, (V) -> Unit ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../-k-mutable-property1/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<T, V> :      KMutableProperty.Setter<V>,     (T, V) -> Unit ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../-k-mutable-property2/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<D, E, V> :      KMutableProperty.Setter<V>,     (D, E, V) -> Unit ``` kotlin Package kotlin.native.ref Package kotlin.native.ref ========================= [kotlin-stdlib](../../../../../index) / [kotlin.native.ref](index) Types ----- **Platform and version requirements:** Native (1.3) #### [WeakReference](-weak-reference/index) Class WeakReference encapsulates weak reference to an object, which could be used to either retrieve a strong reference to an object, or return null, if object was already destroyed by the memory manager. ``` class WeakReference<T : Any> ``` kotlin WeakReference WeakReference ============= [kotlin-stdlib](../../../../../../index) / [kotlin.native.ref](../index) / [WeakReference](index) **Platform and version requirements:** Native (1.3) ``` class WeakReference<T : Any> ``` Class WeakReference encapsulates weak reference to an object, which could be used to either retrieve a strong reference to an object, or return null, if object was already destroyed by the memory manager. Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) Creates a weak reference object pointing to an object. Weak reference doesn't prevent removing object, and is nullified once object is collected. ``` WeakReference(referred: T) ``` Properties ---------- **Platform and version requirements:** Native (1.3) #### <value> Returns either reference to an object or null, if it was collected. ``` val value: T? ``` Functions --------- **Platform and version requirements:** Native (1.3) #### <clear> Clears reference to an object. ``` fun clear() ``` **Platform and version requirements:** Native (1.3) #### <get> Returns either reference to an object or null, if it was collected. ``` fun get(): T? ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin.native.ref](../index) / [WeakReference](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` WeakReference(referred: T) ``` Creates a weak reference object pointing to an object. Weak reference doesn't prevent removing object, and is nullified once object is collected. kotlin clear clear ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native.ref](../index) / [WeakReference](index) / <clear> **Platform and version requirements:** Native (1.3) ``` fun clear() ``` Clears reference to an object. kotlin value value ===== [kotlin-stdlib](../../../../../../index) / [kotlin.native.ref](../index) / [WeakReference](index) / <value> **Platform and version requirements:** Native (1.3) ``` val value: T? ``` Returns either reference to an object or null, if it was collected. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin.native.ref](../index) / [WeakReference](index) / <get> **Platform and version requirements:** Native (1.3) ``` fun get(): T? ``` Returns either reference to an object or null, if it was collected. kotlin with with ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <with> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> with(receiver: T, block: T.() -> R): R ``` Calls the specified function [block](with#kotlin%24with(kotlin.with.T,%20kotlin.Function1((kotlin.with.T,%20kotlin.with.R)))/block) with the given [receiver](with#kotlin%24with(kotlin.with.T,%20kotlin.Function1((kotlin.with.T,%20kotlin.with.R)))/receiver) as its receiver and returns its result. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#with). kotlin arrayOfNulls arrayOfNulls ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [arrayOfNulls](array-of-nulls) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun <reified T> arrayOfNulls(size: Int): Array<T?> ``` Returns an array of objects of the given type with the given [size](array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)/size), initialized with null values. kotlin map map === [kotlin-stdlib](../../../../../index) / [kotlin](index) / <map> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T> Result<T>.map(     transform: (value: T) -> R ): Result<R> ``` Returns the encapsulated result of the given [transform](map#kotlin%24map(kotlin.Result((kotlin.map.T)),%20kotlin.Function1((kotlin.map.T,%20kotlin.map.R)))/transform) function applied to the encapsulated value if this instance represents [success](-result/is-success) or the original encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). Note, that this function rethrows any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [transform](map#kotlin%24map(kotlin.Result((kotlin.map.T)),%20kotlin.Function1((kotlin.map.T,%20kotlin.map.R)))/transform) function. See [mapCatching](map-catching) for an alternative that encapsulates exceptions. kotlin rotateRight rotateRight =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [rotateRight](rotate-right) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Int.rotateRight(bitCount: Int): Int ``` Rotates the binary representation of this [Int](-int/index#kotlin.Int) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Int,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [Int.SIZE\_BITS](-int/-s-i-z-e_-b-i-t-s#kotlin.Int.Companion%24SIZE_BITS) (32) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 32)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Long.rotateRight(bitCount: Int): Long ``` Rotates the binary representation of this [Long](-long/index#kotlin.Long) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Long,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [Long.SIZE\_BITS](-long/-s-i-z-e_-b-i-t-s#kotlin.Long.Companion%24SIZE_BITS) (64) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 64)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Byte.rotateRight(bitCount: Int): Byte ``` Rotates the binary representation of this [Byte](-byte/index#kotlin.Byte) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Byte,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [Byte.SIZE\_BITS](-byte/-s-i-z-e_-b-i-t-s#kotlin.Byte.Companion%24SIZE_BITS) (8) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 8)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Short.rotateRight(bitCount: Int): Short ``` Rotates the binary representation of this [Short](-short/index#kotlin.Short) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Short,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [Short.SIZE\_BITS](-short/-s-i-z-e_-b-i-t-s#kotlin.Short.Companion%24SIZE_BITS) (16) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 16)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UInt.rotateRight(bitCount: Int): UInt ``` Rotates the binary representation of this [UInt](-u-int/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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [UInt.SIZE\_BITS](-u-int/-s-i-z-e_-b-i-t-s) (32) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 32)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun ULong.rotateRight(bitCount: Int): ULong ``` Rotates the binary representation of this [ULong](-u-long/index) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.ULong,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [ULong.SIZE\_BITS](-u-long/-s-i-z-e_-b-i-t-s) (64) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 64)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UByte.rotateRight(bitCount: Int): UByte ``` Rotates the binary representation of this [UByte](-u-byte/index) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.UByte,%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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [UByte.SIZE\_BITS](-u-byte/-s-i-z-e_-b-i-t-s) (8) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 8)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UShort.rotateRight(bitCount: Int): UShort ``` Rotates the binary representation of this [UShort](-u-short/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. Rotating the number right by a negative bit count is the same as rotating it left by the negated bit count: `number.rotateRight(-n) == number.rotateLeft(n)` Rotating by a multiple of [UShort.SIZE\_BITS](-u-short/-s-i-z-e_-b-i-t-s) (16) returns the same number, or more generally `number.rotateRight(n) == number.rotateRight(n % 16)`
programming_docs
kotlin isFinite isFinite ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [isFinite](is-finite) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Double.isFinite(): Boolean ``` ``` fun Float.isFinite(): Boolean ``` Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). kotlin toList toList ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toList](to-list) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Pair<T, T>.toList(): List<T> ``` Converts this pair into a list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val mixedList: List<Any> = Pair(1, "a").toList() println(mixedList) // [1, a] println("mixedList[0] is Int is ${mixedList[0] is Int}") // true println("mixedList[1] is String is ${mixedList[1] is String}") // true val intList: List<Int> = Pair(0, 1).toList() println(intList) // [0, 1] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> Triple<T, T, T>.toList(): List<T> ``` Converts this triple into a list. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val mixedList: List<Any> = Triple(1, "a", 0.5).toList() println(mixedList) // [1, a, 0.5] println("mixedList[0] is Int is ${mixedList[0] is Int}") // true println("mixedList[1] is String is ${mixedList[1] is String}") // true println("mixedList[2] is Double is ${mixedList[2] is Double}") // true val intList: List<Int> = Triple(0, 1, 2).toList() println(intList) // [0, 1, 2] //sampleEnd } ``` kotlin run run === [kotlin-stdlib](../../../../../index) / [kotlin](index) / <run> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <R> run(block: () -> R): R ``` Calls the specified function [block](run#kotlin%24run(kotlin.Function0((kotlin.run.R)))/block) and returns its result. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#run). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> T.run(block: T.() -> R): R ``` Calls the specified function [block](run#kotlin%24run(kotlin.run.T,%20kotlin.Function1((kotlin.run.T,%20kotlin.run.R)))/block) with `this` value as its receiver and returns its result. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#run). kotlin takeHighestOneBit takeHighestOneBit ================= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [takeHighestOneBit](take-highest-one-bit) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Int.takeHighestOneBit(): Int ``` Returns a number having a single bit set in the position of the most significant set bit of this [Int](-int/index#kotlin.Int) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Long.takeHighestOneBit(): Long ``` Returns a number having a single bit set in the position of the most significant set bit of this [Long](-long/index#kotlin.Long) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Byte.takeHighestOneBit(): Byte ``` Returns a number having a single bit set in the position of the most significant set bit of this [Byte](-byte/index#kotlin.Byte) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Short.takeHighestOneBit(): Short ``` Returns a number having a single bit set in the position of the most significant set bit of this [Short](-short/index#kotlin.Short) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.takeHighestOneBit(): UInt ``` Returns a number having a single bit set in the position of the most significant set bit of this [UInt](-u-int/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.takeHighestOneBit(): ULong ``` Returns a number having a single bit set in the position of the most significant set bit of this [ULong](-u-long/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.takeHighestOneBit(): UByte ``` Returns a number having a single bit set in the position of the most significant set bit of this [UByte](-u-byte/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.takeHighestOneBit(): UShort ``` Returns a number having a single bit set in the position of the most significant set bit of this [UShort](-u-short/index) number, or zero, if this number is zero. kotlin arrayOf arrayOf ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [arrayOf](array-of) **Platform and version requirements:** JVM (1.0), Native (1.3) ``` fun <reified T> arrayOf(vararg elements: T): Array<T> ``` **Platform and version requirements:** JS (1.1) ``` fun <T> arrayOf(vararg elements: T): Array<T> ``` Returns an array containing the specified elements. kotlin takeLowestOneBit takeLowestOneBit ================ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [takeLowestOneBit](take-lowest-one-bit) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Int.takeLowestOneBit(): Int ``` Returns a number having a single bit set in the position of the least significant set bit of this [Int](-int/index#kotlin.Int) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Long.takeLowestOneBit(): Long ``` Returns a number having a single bit set in the position of the least significant set bit of this [Long](-long/index#kotlin.Long) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Byte.takeLowestOneBit(): Byte ``` Returns a number having a single bit set in the position of the least significant set bit of this [Byte](-byte/index#kotlin.Byte) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Short.takeLowestOneBit(): Short ``` Returns a number having a single bit set in the position of the least significant set bit of this [Short](-short/index#kotlin.Short) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.takeLowestOneBit(): UInt ``` Returns a number having a single bit set in the position of the least significant set bit of this [UInt](-u-int/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.takeLowestOneBit(): ULong ``` Returns a number having a single bit set in the position of the least significant set bit of this [ULong](-u-long/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.takeLowestOneBit(): UByte ``` Returns a number having a single bit set in the position of the least significant set bit of this [UByte](-u-byte/index) number, or zero, if this number is zero. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.takeLowestOneBit(): UShort ``` Returns a number having a single bit set in the position of the least significant set bit of this [UShort](-u-short/index) number, or zero, if this number is zero. kotlin synchronized synchronized ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / <synchronized> **Platform and version requirements:** JVM (1.0) ``` inline fun <R> synchronized(lock: Any, block: () -> R): R ``` **Platform and version requirements:** JS (1.1) ``` @DeprecatedSinceKotlin("1.6") inline fun <R> synchronized(     lock: Any,     block: () -> R ): R ``` **Deprecated:** Synchronization on any object is not supported in Kotlin/JS Executes the given function [block](synchronized#kotlin%24synchronized(kotlin.Any,%20kotlin.Function0((kotlin.synchronized.R)))/block) while holding the monitor of the given object [lock](synchronized#kotlin%24synchronized(kotlin.Any,%20kotlin.Function0((kotlin.synchronized.R)))/lock). kotlin onSuccess onSuccess ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [onSuccess](on-success) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <T> Result<T>.onSuccess(     action: (value: T) -> Unit ): Result<T> ``` Performs the given [action](on-success#kotlin%24onSuccess(kotlin.Result((kotlin.onSuccess.T)),%20kotlin.Function1((kotlin.onSuccess.T,%20kotlin.Unit)))/action) on the encapsulated value if this instance represents [success](-result/is-success). Returns the original `Result` unchanged. kotlin Package kotlin Package kotlin ============== [kotlin-stdlib](../../../../../index) / [kotlin](index) Core functions and types, available on all supported platforms. Types ----- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Annotation](-annotation) Base interface implicitly implemented by all annotation interfaces. See [Kotlin language documentation](../../../../../docs/annotations) for more information on annotations. ``` interface Annotation ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Any](-any/index) The root of the Kotlin class hierarchy. Every Kotlin class has [Any](-any/index#kotlin.Any) as a superclass. ``` open class Any ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Array](-array/index) Represents an array (specifically, a Java array when targeting the JVM platform). Array instances can be created using the [arrayOf](array-of#kotlin%24arrayOf(kotlin.Array((kotlin.arrayOf.T)))), [arrayOfNulls](array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)) and [emptyArray](empty-array#kotlin%24emptyArray()) standard library functions. See [Kotlin language documentation](../../../../../docs/basic-types#arrays) for more information on arrays. ``` class Array<T> ``` **Platform and version requirements:** Native (1.3) #### [ArrayIndexOutOfBoundsException](-array-index-out-of-bounds-exception/index) ``` open class ArrayIndexOutOfBoundsException :      IndexOutOfBoundsException ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Boolean](-boolean/index) Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are represented as values of the primitive type `boolean`. ``` class Boolean : Comparable<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BooleanArray](-boolean-array/index) An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`. ``` class BooleanArray ``` **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) #### [ByteArray](-byte-array/index) An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`. ``` class ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Char](-char/index) Represents a 16-bit Unicode character. ``` class Char : Comparable<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharArray](-char-array/index) An array of chars. When targeting the JVM, instances of this class are represented as `char[]`. ``` class CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharSequence](-char-sequence/index) Represents a readable sequence of [Char](-char/index#kotlin.Char) values. ``` interface CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Comparable](-comparable/index) Classes which inherit from this interface have a defined total ordering between their instances. ``` interface Comparable<in T> ``` #### [Comparator](-comparator/index) Provides a comparison function for imposing a total ordering between instances of the type [T](-comparator/index#T). **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun interface Comparator<T> ``` **Platform and version requirements:** JVM (1.1) ``` typealias Comparator<T> = Comparator<T> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [DeepRecursiveFunction](-deep-recursive-function/index) Defines deep recursive function that keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack. To initiate a call to this deep recursive function use its <invoke> function. As a rule of thumb, it should be used if recursion goes deeper than a thousand calls. ``` class DeepRecursiveFunction<T, R> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [DeepRecursiveScope](-deep-recursive-scope/index) A scope class for [DeepRecursiveFunction](-deep-recursive-function/index) function declaration that defines [callRecursive](-deep-recursive-scope/call-recursive) methods to recursively call this function or another [DeepRecursiveFunction](-deep-recursive-function/index) putting the call activation frame on the heap. ``` sealed class DeepRecursiveScope<T, R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DeprecationLevel](-deprecation-level/index) Possible levels of a deprecation. The level specifies how the deprecated element usages are reported in code. ``` enum class DeprecationLevel ``` **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) #### [DoubleArray](-double-array/index) An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`. ``` class DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Enum](-enum/index) The common base class of all enum classes. See the [Kotlin language documentation](../../../../../docs/enum-classes) for more information on enum classes. ``` abstract class Enum<E : Enum<E>> : Comparable<E> ``` **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) #### [FloatArray](-float-array/index) An array of floats. When targeting the JVM, instances of this class are represented as `float[]`. ``` class FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Function](-function) Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. ``` interface Function<out R> ``` **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) #### [IntArray](-int-array/index) An array of ints. When targeting the JVM, instances of this class are represented as `int[]`. ``` class IntArray ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KotlinVersion](-kotlin-version/index) Represents a version of the Kotlin standard library. ``` class KotlinVersion : Comparable<KotlinVersion> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Lazy](-lazy/index) Represents a value with lazy initialization. ``` interface Lazy<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LazyThreadSafetyMode](-lazy-thread-safety-mode/index) Specifies how a [Lazy](-lazy/index) instance synchronizes initialization among multiple threads. ``` enum class LazyThreadSafetyMode ``` **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) #### [LongArray](-long-array/index) An array of longs. When targeting the JVM, instances of this class are represented as `long[]`. ``` class LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Nothing](-nothing) Nothing has no instances. You can use Nothing to represent "a value that never exists": for example, if a function has the return type of Nothing, it means that it never returns (always throws an exception). ``` class Nothing ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Number](-number/index) Superclass for all platform classes representing numeric values. ``` abstract class Number ``` **Platform and version requirements:** Native (1.3) #### [OutOfMemoryError](-out-of-memory-error/index) ``` open class OutOfMemoryError : Error ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Pair](-pair/index) Represents a generic pair of two values. ``` data class Pair<out A, out B> : Serializable ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Result](-result/index) A discriminated union that encapsulates a successful outcome with a value of type [T](-result/index#T) or a failure with an arbitrary [Throwable](-throwable/index#kotlin.Throwable) exception. ``` class Result<out T> : Serializable ``` **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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ShortArray](-short-array/index) An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`. ``` class ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [String](-string/index) The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. ``` class String : Comparable<String>, CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Throwable](-throwable/index) The base class for all errors and exceptions. Only instances of this class can be thrown or caught. ``` open class Throwable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Triple](-triple/index) Represents a triad of values ``` data class Triple<out A, out B, out C> : Serializable ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UByte](-u-byte/index) ``` class UByte : Comparable<UByte> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UByteArray](-u-byte-array/index) ``` class UByteArray : Collection<UByte> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UInt](-u-int/index) ``` class UInt : Comparable<UInt> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UIntArray](-u-int-array/index) ``` class UIntArray : Collection<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULong](-u-long/index) ``` class ULong : Comparable<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ULongArray](-u-long-array/index) ``` class ULongArray : Collection<ULong> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Unit](-unit/index) The type with only one value: the `Unit` object. This type corresponds to the `void` type in Java. ``` object Unit ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UShort](-u-short/index) ``` class UShort : Comparable<UShort> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UShortArray](-u-short-array/index) ``` class UShortArray : Collection<UShort> ``` Annotations ----------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [BuilderInference](-builder-inference/index) Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. ``` annotation class BuilderInference ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ContextFunctionTypeParams](-context-function-type-params/index) ``` annotation class ContextFunctionTypeParams ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Deprecated](-deprecated/index) Marks the annotated declaration as deprecated. ``` annotation class Deprecated ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [DeprecatedSinceKotlin](-deprecated-since-kotlin/index) Marks the annotated declaration as deprecated. In contrast to [Deprecated](-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](-deprecated-since-kotlin/hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](-deprecated-since-kotlin/error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](-deprecated-since-kotlin/warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. ``` annotation class DeprecatedSinceKotlin ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [DslMarker](-dsl-marker/index) When applied to annotation class X specifies that X defines a DSL language ``` annotation class DslMarker ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalMultiplatform](-experimental-multiplatform/index) The experimental multiplatform support API marker. ``` annotation class ExperimentalMultiplatform ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalStdlibApi](-experimental-stdlib-api/index) This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. ``` annotation class ExperimentalStdlibApi ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [ExperimentalSubclassOptIn](-experimental-subclass-opt-in/index) This annotation marks the experimental preview of the language feature [SubclassOptInRequired](-subclass-opt-in-required/index). ``` annotation class ExperimentalSubclassOptIn ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalUnsignedTypes](-experimental-unsigned-types/index) Marks the API that is dependent on the experimental unsigned types, including those types themselves. ``` annotation class ExperimentalUnsignedTypes ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExtensionFunctionType](-extension-function-type/index) Signifies that the annotated functional type represents an extension function. ``` annotation class ExtensionFunctionType ``` **Platform and version requirements:** JVM (1.3) #### [Metadata](-metadata/index) This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. ``` annotation class Metadata ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [OptIn](-opt-in/index) Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](-opt-in/index), its usages are **not** required to opt in to that API. ``` annotation class OptIn ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [OptionalExpectation](-optional-expectation/index) Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. ``` annotation class OptionalExpectation ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [OverloadResolutionByLambdaReturnType](-overload-resolution-by-lambda-return-type/index) Enables overload selection based on the type of the value returned from lambda argument. ``` annotation class OverloadResolutionByLambdaReturnType ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ParameterName](-parameter-name/index) Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). ``` annotation class ParameterName ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [PublishedApi](-published-api/index) When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. ``` annotation class PublishedApi ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ReplaceWith](-replace-with/index) Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. ``` annotation class ReplaceWith ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RequiresOptIn](-requires-opt-in/index) Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. ``` annotation class RequiresOptIn ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SinceKotlin](-since-kotlin/index) Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. ``` annotation class SinceKotlin ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [SubclassOptInRequired](-subclass-opt-in-required/index) Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. ``` annotation class SubclassOptInRequired ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Suppress](-suppress/index) Suppresses the given compilation warnings in the annotated element. ``` annotation class Suppress ``` #### [Throws](-throws/index) This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. **Platform and version requirements:** Native (1.4) ``` annotation class Throws ``` **Platform and version requirements:** JVM (1.4) ``` typealias Throws = Throws ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [UnsafeVariance](-unsafe-variance/index) Suppresses errors about variance conflict ``` annotation class UnsafeVariance ``` Exceptions ---------- #### [ArithmeticException](-arithmetic-exception/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 ``` #### [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 ``` #### [ClassCastException](-class-cast-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ClassCastException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias ClassCastException = ClassCastException ``` #### [ConcurrentModificationException](-concurrent-modification-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ConcurrentModificationException : RuntimeException ``` **Platform and version requirements:** JVM (1.3) ``` typealias ConcurrentModificationException = ConcurrentModificationException ``` #### [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 ``` #### [IllegalArgumentException](-illegal-argument-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalArgumentException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalArgumentException = IllegalArgumentException ``` #### [IllegalStateException](-illegal-state-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalStateException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalStateException = IllegalStateException ``` #### [IndexOutOfBoundsException](-index-out-of-bounds-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IndexOutOfBoundsException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IndexOutOfBoundsException = IndexOutOfBoundsException ``` **Platform and version requirements:** JVM (1.0) #### [KotlinNullPointerException](-kotlin-null-pointer-exception/index) ``` open class KotlinNullPointerException : NullPointerException ``` #### [NoSuchElementException](-no-such-element-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NoSuchElementException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NoSuchElementException = NoSuchElementException ``` **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 ``` #### [NoWhenBranchMatchedException](-no-when-branch-matched-exception/index) **Platform and version requirements:** ``` open class NoWhenBranchMatchedException : RuntimeException ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` open class NoWhenBranchMatchedException : RuntimeException ``` #### [NullPointerException](-null-pointer-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NullPointerException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NullPointerException = NullPointerException ``` #### [NumberFormatException](-number-format-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NumberFormatException : IllegalArgumentException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NumberFormatException = NumberFormatException ``` #### [RuntimeException](-runtime-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class RuntimeException : Exception ``` **Platform and version requirements:** JVM (1.1) ``` typealias RuntimeException = RuntimeException ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [TypeCastException](-type-cast-exception/index) ``` open class TypeCastException : ClassCastException ``` #### [UninitializedPropertyAccessException](-uninitialized-property-access-exception/index) **Platform and version requirements:** ``` class UninitializedPropertyAccessException : RuntimeException ``` **Platform and version requirements:** JVM (1.0) ``` class UninitializedPropertyAccessException : RuntimeException ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class UninitializedPropertyAccessException :      RuntimeException ``` #### [UnsupportedOperationException](-unsupported-operation-exception/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 ``` Extensions for External Classes ------------------------------- **Platform and version requirements:** JVM (1.0) #### [java.math.BigDecimal](java.math.-big-decimal/index) **Platform and version requirements:** JVM (1.0) #### [java.math.BigInteger](java.math.-big-integer/index) Properties ---------- **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### <code> Returns the code of this Char. ``` val Char.code: Int ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [isInitialized](is-initialized) Returns `true` if this lateinit property has been assigned a value, and `false` otherwise. ``` val KProperty0<*>.isInitialized: Boolean ``` **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> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [suppressedExceptions](suppressed-exceptions) Returns a list of all exceptions that were suppressed in order to deliver this exception. ``` val Throwable.suppressedExceptions: List<Throwable> ``` Functions --------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [addSuppressed](add-suppressed) When supported by the platform, adds the specified exception to the list of exceptions that were suppressed in order to deliver this exception. ``` fun Throwable.addSuppressed(exception: Throwable) ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### <also> Calls the specified function [block](also#kotlin%24also(kotlin.also.T,%20kotlin.Function1((kotlin.also.T,%20kotlin.Unit)))/block) with `this` value as its argument and returns `this` value. ``` fun <T> T.also(block: (T) -> Unit): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <apply> Calls the specified function [block](apply#kotlin%24apply(kotlin.apply.T,%20kotlin.Function1((kotlin.apply.T,%20kotlin.Unit)))/block) with `this` value as its receiver and returns `this` value. ``` fun <T> T.apply(block: T.() -> Unit): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [arrayOf](array-of) Returns an array containing the specified elements. ``` fun <T> arrayOf(vararg elements: T): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [arrayOfNulls](array-of-nulls) Returns an array of objects of the given type with the given [size](array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)/size), initialized with null values. ``` fun <T> arrayOfNulls(size: Int): Array<T?> ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### <assert> Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) if the [value](assert#kotlin%24assert(kotlin.Boolean)/value) is false and runtime assertions have been enabled on the JVM using the *-ea* JVM option. ``` fun assert(value: Boolean) ``` Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) calculated by [lazyMessage](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false and runtime assertions have been enabled on the JVM using the *-ea* JVM option. ``` fun assert(value: Boolean, lazyMessage: () -> Any) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [booleanArrayOf](boolean-array-of) Returns an array containing the specified boolean values. ``` fun booleanArrayOf(vararg elements: Boolean): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [byteArrayOf](byte-array-of) Returns an array containing the specified [Byte](-byte/index#kotlin.Byte) numbers. ``` fun byteArrayOf(vararg elements: Byte): ByteArray ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [Char](-char) Creates a Char with the specified [code](-char#kotlin%24Char(kotlin.Int)/code), or throws an exception if the [code](-char#kotlin%24Char(kotlin.Int)/code) is out of `Char.MIN_VALUE.code..Char.MAX_VALUE.code`. ``` fun Char(code: Int): Char ``` Creates a Char with the specified [code](-char#kotlin%24Char(kotlin.UShort)/code). ``` fun Char(code: UShort): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [charArrayOf](char-array-of) Returns an array containing the specified characters. ``` fun charArrayOf(vararg elements: Char): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <check> Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) if the [value](check#kotlin%24check(kotlin.Boolean)/value) is false. ``` fun check(value: Boolean) ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the result of calling [lazyMessage](check#kotlin%24check(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](check#kotlin%24check(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false. ``` fun check(value: Boolean, lazyMessage: () -> Any) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [checkNotNull](check-not-null) Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) if the [value](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?)/value) is null. Otherwise returns the not null value. ``` fun <T : Any> checkNotNull(value: T?): T ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the result of calling [lazyMessage](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?,%20kotlin.Function0((kotlin.Any)))/value) is null. Otherwise returns the not null value. ``` fun <T : Any> checkNotNull(     value: T?,     lazyMessage: () -> Any ): 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:** JVM (1.4), JS (1.4), Native (1.4) #### [countLeadingZeroBits](count-leading-zero-bits) Counts the number of consecutive most significant bits that are zero in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. ``` fun Byte.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Short](-short/index#kotlin.Short) number. ``` fun Short.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UInt](-u-int/index) number. ``` fun UInt.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [ULong](-u-long/index) number. ``` fun ULong.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UByte](-u-byte/index) number. ``` fun UByte.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UShort](-u-short/index) number. ``` fun UShort.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Int](-int/index#kotlin.Int) number. ``` fun Int.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Long](-long/index#kotlin.Long) number. ``` fun Long.countLeadingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countOneBits](count-one-bits) Counts the number of set bits in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. ``` fun Byte.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Short](-short/index#kotlin.Short) number. ``` fun Short.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UInt](-u-int/index) number. ``` fun UInt.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [ULong](-u-long/index) number. ``` fun ULong.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UByte](-u-byte/index) number. ``` fun UByte.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UShort](-u-short/index) number. ``` fun UShort.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Int](-int/index#kotlin.Int) number. ``` fun Int.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Long](-long/index#kotlin.Long) number. ``` fun Long.countOneBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countTrailingZeroBits](count-trailing-zero-bits) Counts the number of consecutive least significant bits that are zero in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. ``` fun Byte.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Short](-short/index#kotlin.Short) number. ``` fun Short.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UInt](-u-int/index) number. ``` fun UInt.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [ULong](-u-long/index) number. ``` fun ULong.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UByte](-u-byte/index) number. ``` fun UByte.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UShort](-u-short/index) number. ``` fun UShort.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Int](-int/index#kotlin.Int) number. ``` fun Int.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Long](-long/index#kotlin.Long) number. ``` fun Long.countTrailingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [doubleArrayOf](double-array-of) Returns an array containing the specified [Double](-double/index#kotlin.Double) numbers. ``` fun doubleArrayOf(vararg elements: Double): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [emptyArray](empty-array) Returns an empty array of the specified type [T](empty-array#T). ``` fun <T> emptyArray(): Array<T> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [enumValueOf](enum-value-of) Returns an enum entry with specified name. ``` fun <T : Enum<T>> enumValueOf(name: String): T ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [enumValues](enum-values) Returns an array containing enum T entries. ``` fun <T : Enum<T>> enumValues(): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <error> Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the given [message](error#kotlin%24error(kotlin.Any)/message). ``` fun error(message: Any): Nothing ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [floatArrayOf](float-array-of) Returns an array containing the specified [Float](-float/index#kotlin.Float) numbers. ``` fun floatArrayOf(vararg elements: Float): FloatArray ``` **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 Byte.floorDiv(other: Byte): Int ``` ``` fun Byte.floorDiv(other: Short): Int ``` ``` fun Byte.floorDiv(other: Int): Int ``` ``` fun Byte.floorDiv(other: Long): Long ``` ``` fun Short.floorDiv(other: Byte): Int ``` ``` fun Short.floorDiv(other: Short): Int ``` ``` fun Short.floorDiv(other: Int): Int ``` ``` fun Short.floorDiv(other: Long): Long ``` ``` fun Int.floorDiv(other: Byte): Int ``` ``` fun Int.floorDiv(other: Short): Int ``` ``` fun Int.floorDiv(other: Int): Int ``` ``` fun Int.floorDiv(other: Long): Long ``` ``` 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.3), JS (1.3), Native (1.3) #### <fold> Returns the result of [onSuccess](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onSuccess) for the encapsulated value if this instance represents [success](-result/is-success) or the result of [onFailure](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onFailure) function for the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). ``` fun <R, T> Result<T>.fold(     onSuccess: (value: T) -> R,     onFailure: (exception: Throwable) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrDefault](get-or-default) Returns the encapsulated value if this instance represents [success](-result/is-success) or the [defaultValue](get-or-default#kotlin%24getOrDefault(kotlin.Result((kotlin.getOrDefault.T)),%20kotlin.getOrDefault.R)/defaultValue) if it is [failure](-result/is-failure). ``` fun <R, T : R> Result<T>.getOrDefault(defaultValue: R): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrElse](get-or-else) Returns the encapsulated value if this instance represents [success](-result/is-success) or the result of [onFailure](get-or-else#kotlin%24getOrElse(kotlin.Result((kotlin.getOrElse.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.getOrElse.R)))/onFailure) function for the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). ``` fun <R, T : R> Result<T>.getOrElse(     onFailure: (exception: Throwable) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrThrow](get-or-throw) Returns the encapsulated value if this instance represents [success](-result/is-success) or throws the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). ``` fun <T> Result<T>.getOrThrow(): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](get-value) An extension operator that allows delegating a read-only property of type [V](get-value#V) to a property reference to a property of type [V](get-value#V) or its subtype. ``` operator fun <V> KProperty0<V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V ``` An extension operator that allows delegating a read-only member or extension property of type [V](get-value#V) to a property reference to a member or extension property of type [V](get-value#V) or its subtype. ``` operator fun <T, V> KProperty1<T, V>.getValue(     thisRef: T,     property: KProperty<*> ): V ``` An extension to delegate a read-only property of type [T](get-value#T) to an instance of [Lazy](-lazy/index). ``` operator fun <T> Lazy<T>.getValue(     thisRef: Any?,     property: KProperty<*> ): T ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [hashCode](hash-code) Returns a hash code value for the object or zero if the object is `null`. ``` fun Any?.hashCode(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [intArrayOf](int-array-of) Returns an array containing the specified [Int](-int/index#kotlin.Int) numbers. ``` fun intArrayOf(vararg elements: Int): IntArray ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### <invoke> Initiates a call to this deep recursive function, forming a root of the call tree. ``` operator fun <T, R> DeepRecursiveFunction<T, R>.invoke(     value: T ): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isFinite](is-finite) Returns `true` if the argument is a finite floating-point value; returns `false` otherwise (for `NaN` and infinity arguments). ``` fun Double.isFinite(): Boolean ``` ``` fun Float.isFinite(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isInfinite](is-infinite) Returns `true` if this value is infinitely large in magnitude. ``` fun Double.isInfinite(): Boolean ``` ``` fun Float.isInfinite(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNaN](is-na-n) Returns `true` if the specified number is a Not-a-Number (NaN) value, `false` otherwise. ``` fun Double.isNaN(): Boolean ``` ``` fun Float.isNaN(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <lazy> Creates a new instance of the Lazy that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.Function0((kotlin.lazy.T)))/initializer) and the default thread-safety mode LazyThreadSafetyMode.SYNCHRONIZED. ``` fun <T> lazy(initializer: () -> T): Lazy<T> ``` Creates a new instance of the [Lazy](-lazy/index) that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.LazyThreadSafetyMode,%20kotlin.Function0((kotlin.lazy.T)))/initializer). ``` fun <T> lazy(     mode: LazyThreadSafetyMode,     initializer: () -> T ): Lazy<T> ``` ``` fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lazyOf](lazy-of) Creates a new instance of the [Lazy](-lazy/index) that is already initialized with the specified [value](lazy-of#kotlin%24lazyOf(kotlin.lazyOf.T)/value). ``` fun <T> lazyOf(value: T): Lazy<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <let> Calls the specified function [block](let#kotlin%24let(kotlin.let.T,%20kotlin.Function1((kotlin.let.T,%20kotlin.let.R)))/block) with `this` value as its argument and returns its result. ``` fun <T, R> T.let(block: (T) -> R): R ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [longArrayOf](long-array-of) Returns an array containing the specified [Long](-long/index#kotlin.Long) numbers. ``` fun longArrayOf(vararg elements: Long): LongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <map> Returns the encapsulated result of the given [transform](map#kotlin%24map(kotlin.Result((kotlin.map.T)),%20kotlin.Function1((kotlin.map.T,%20kotlin.map.R)))/transform) function applied to the encapsulated value if this instance represents [success](-result/is-success) or the original encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). ``` fun <R, T> Result<T>.map(     transform: (value: T) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [mapCatching](map-catching) Returns the encapsulated result of the given [transform](map-catching#kotlin%24mapCatching(kotlin.Result((kotlin.mapCatching.T)),%20kotlin.Function1((kotlin.mapCatching.T,%20kotlin.mapCatching.R)))/transform) function applied to the encapsulated value if this instance represents [success](-result/is-success) or the original encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). ``` fun <R, T> Result<T>.mapCatching(     transform: (value: T) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### <mod> Calculates the remainder of flooring division of this value by the other value. ``` fun Byte.mod(other: Byte): Byte ``` ``` fun Byte.mod(other: Short): Short ``` ``` fun Byte.mod(other: Int): Int ``` ``` fun Byte.mod(other: Long): Long ``` ``` fun Short.mod(other: Byte): Byte ``` ``` fun Short.mod(other: Short): Short ``` ``` fun Short.mod(other: Int): Int ``` ``` fun Short.mod(other: Long): Long ``` ``` fun Int.mod(other: Byte): Byte ``` ``` fun Int.mod(other: Short): Short ``` ``` fun Int.mod(other: Int): Int ``` ``` fun Int.mod(other: Long): Long ``` ``` fun Long.mod(other: Byte): Byte ``` ``` fun Long.mod(other: Short): Short ``` ``` fun Long.mod(other: Int): Int ``` ``` fun Long.mod(other: Long): Long ``` ``` fun Float.mod(other: Float): Float ``` ``` fun Float.mod(other: Double): Double ``` ``` fun Double.mod(other: Float): Double ``` ``` fun Double.mod(other: Double): Double ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [onFailure](on-failure) Performs the given [action](on-failure#kotlin%24onFailure(kotlin.Result((kotlin.onFailure.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.Unit)))/action) on the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure). Returns the original `Result` unchanged. ``` fun <T> Result<T>.onFailure(     action: (exception: Throwable) -> Unit ): Result<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [onSuccess](on-success) Performs the given [action](on-success#kotlin%24onSuccess(kotlin.Result((kotlin.onSuccess.T)),%20kotlin.Function1((kotlin.onSuccess.T,%20kotlin.Unit)))/action) on the encapsulated value if this instance represents [success](-result/is-success). Returns the original `Result` unchanged. ``` fun <T> Result<T>.onSuccess(     action: (value: T) -> Unit ): Result<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Concatenates this string with the string representation of the given [other](plus#kotlin%24plus(kotlin.String?,%20kotlin.Any?)/other) object. If either the receiver or the [other](plus#kotlin%24plus(kotlin.String?,%20kotlin.Any?)/other) object are null, they are represented as the string "null". ``` operator fun String?.plus(other: Any?): String ``` #### [printStackTrace](print-stack-trace) **Platform and version requirements:** JVM (1.0) 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) ``` **Platform and version requirements:** JVM (1.0) 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) ``` **Platform and version requirements:** JVM (1.0), JS (1.4), Native (1.4) Prints the [detailed description](stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output or standard error output. ``` fun Throwable.printStackTrace() ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### <recover> Returns the encapsulated result of the given [transform](recover#kotlin%24recover(kotlin.Result((kotlin.recover.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recover.R)))/transform) function applied to the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure) or the original encapsulated value if it is [success](-result/is-success). ``` fun <R, T : R> Result<T>.recover(     transform: (exception: Throwable) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [recoverCatching](recover-catching) Returns the encapsulated result of the given [transform](recover-catching#kotlin%24recoverCatching(kotlin.Result((kotlin.recoverCatching.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recoverCatching.R)))/transform) function applied to the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure) or the original encapsulated value if it is [success](-result/is-success). ``` fun <R, T : R> Result<T>.recoverCatching(     transform: (exception: Throwable) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <repeat> Executes the given function [action](repeat#kotlin%24repeat(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/action) specified number of [times](repeat#kotlin%24repeat(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/times). ``` fun repeat(times: Int, action: (Int) -> Unit) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <require> Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) if the [value](require#kotlin%24require(kotlin.Boolean)/value) is false. ``` fun require(value: Boolean) ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) with the result of calling [lazyMessage](require#kotlin%24require(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](require#kotlin%24require(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false. ``` fun require(value: Boolean, lazyMessage: () -> Any) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [requireNotNull](require-not-null) Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) if the [value](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?)/value) is null. Otherwise returns the not null value. ``` fun <T : Any> requireNotNull(value: T?): T ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) with the result of calling [lazyMessage](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?,%20kotlin.Function0((kotlin.Any)))/value) is null. Otherwise returns the not null value. ``` fun <T : Any> requireNotNull(     value: T?,     lazyMessage: () -> Any ): T ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateLeft](rotate-left) Rotates the binary representation of this [Byte](-byte/index#kotlin.Byte) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Byte,%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 Byte.rotateLeft(bitCount: Int): Byte ``` Rotates the binary representation of this [Short](-short/index#kotlin.Short) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Short,%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 Short.rotateLeft(bitCount: Int): Short ``` Rotates the binary representation of this [UInt](-u-int/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 ``` Rotates the binary representation of this [ULong](-u-long/index) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.ULong,%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 ULong.rotateLeft(bitCount: Int): ULong ``` Rotates the binary representation of this [UByte](-u-byte/index) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.UByte,%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 UByte.rotateLeft(bitCount: Int): UByte ``` Rotates the binary representation of this [UShort](-u-short/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 ``` Rotates the binary representation of this [Int](-int/index#kotlin.Int) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Int,%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 Int.rotateLeft(bitCount: Int): Int ``` Rotates the binary representation of this [Long](-long/index#kotlin.Long) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Long,%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 Long.rotateLeft(bitCount: Int): Long ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](rotate-right) Rotates the binary representation of this [Byte](-byte/index#kotlin.Byte) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Byte,%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 Byte.rotateRight(bitCount: Int): Byte ``` Rotates the binary representation of this [Short](-short/index#kotlin.Short) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Short,%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 Short.rotateRight(bitCount: Int): Short ``` Rotates the binary representation of this [UInt](-u-int/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 ``` Rotates the binary representation of this [ULong](-u-long/index) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.ULong,%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 ULong.rotateRight(bitCount: Int): ULong ``` Rotates the binary representation of this [UByte](-u-byte/index) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.UByte,%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 UByte.rotateRight(bitCount: Int): UByte ``` Rotates the binary representation of this [UShort](-u-short/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 ``` Rotates the binary representation of this [Int](-int/index#kotlin.Int) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Int,%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 Int.rotateRight(bitCount: Int): Int ``` Rotates the binary representation of this [Long](-long/index#kotlin.Long) number right by the specified [bitCount](rotate-right#kotlin%24rotateRight(kotlin.Long,%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 Long.rotateRight(bitCount: Int): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <run> Calls the specified function [block](run#kotlin%24run(kotlin.Function0((kotlin.run.R)))/block) and returns its result. ``` fun <R> run(block: () -> R): R ``` Calls the specified function [block](run#kotlin%24run(kotlin.run.T,%20kotlin.Function1((kotlin.run.T,%20kotlin.run.R)))/block) with `this` value as its receiver and returns its result. ``` fun <T, R> T.run(block: T.() -> R): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [runCatching](run-catching) Calls the specified function [block](run-catching#kotlin%24runCatching(kotlin.Function0((kotlin.runCatching.R)))/block) and returns its encapsulated result if invocation was successful, catching any [Throwable](-throwable/index#kotlin.Throwable) exception that was thrown from the [block](run-catching#kotlin%24runCatching(kotlin.Function0((kotlin.runCatching.R)))/block) function execution and encapsulating it as a failure. ``` fun <R> runCatching(block: () -> R): Result<R> ``` Calls the specified function [block](run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) with `this` value as its receiver and returns its encapsulated result if invocation was successful, catching any [Throwable](-throwable/index#kotlin.Throwable) exception that was thrown from the [block](run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) function execution and encapsulating it as a failure. ``` fun <T, R> T.runCatching(block: T.() -> R): Result<R> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [setValue](set-value) An extension operator that allows delegating a mutable property of type [V](set-value#V) to a property reference to a mutable property of the same type [V](set-value#V). ``` operator fun <V> KMutableProperty0<V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` An extension operator that allows delegating a mutable member or extension property of type [V](set-value#V) to a property reference to a member or extension mutable property of the same type [V](set-value#V). ``` operator fun <T, V> KMutableProperty1<T, V>.setValue(     thisRef: T,     property: KProperty<*>,     value: V) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [shortArrayOf](short-array-of) Returns an array containing the specified [Short](-short/index#kotlin.Short) numbers. ``` fun shortArrayOf(vararg elements: Short): ShortArray ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [stackTraceToString](stack-trace-to-string) Returns the detailed description of this throwable with its stack trace. ``` fun Throwable.stackTraceToString(): String ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### <suspend> ``` fun <R> suspend(block: suspend () -> R): suspend () -> R ``` #### <synchronized> Executes the given function [block](synchronized#kotlin%24synchronized(kotlin.Any,%20kotlin.Function0((kotlin.synchronized.R)))/block) while holding the monitor of the given object [lock](synchronized#kotlin%24synchronized(kotlin.Any,%20kotlin.Function0((kotlin.synchronized.R)))/lock). **Platform and version requirements:** JVM (1.0) ``` fun <R> synchronized(lock: Any, block: () -> R): R ``` **Platform and version requirements:** JS (1.1) ``` fun <R> synchronized(lock: Any, block: () -> R): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeHighestOneBit](take-highest-one-bit) Returns a number having a single bit set in the position of the most significant set bit of this [Byte](-byte/index#kotlin.Byte) number, or zero, if this number is zero. ``` fun Byte.takeHighestOneBit(): Byte ``` Returns a number having a single bit set in the position of the most significant set bit of this [Short](-short/index#kotlin.Short) number, or zero, if this number is zero. ``` fun Short.takeHighestOneBit(): Short ``` Returns a number having a single bit set in the position of the most significant set bit of this [UInt](-u-int/index) number, or zero, if this number is zero. ``` fun UInt.takeHighestOneBit(): UInt ``` Returns a number having a single bit set in the position of the most significant set bit of this [ULong](-u-long/index) number, or zero, if this number is zero. ``` fun ULong.takeHighestOneBit(): ULong ``` Returns a number having a single bit set in the position of the most significant set bit of this [UByte](-u-byte/index) number, or zero, if this number is zero. ``` fun UByte.takeHighestOneBit(): UByte ``` Returns a number having a single bit set in the position of the most significant set bit of this [UShort](-u-short/index) number, or zero, if this number is zero. ``` fun UShort.takeHighestOneBit(): UShort ``` Returns a number having a single bit set in the position of the most significant set bit of this [Int](-int/index#kotlin.Int) number, or zero, if this number is zero. ``` fun Int.takeHighestOneBit(): Int ``` Returns a number having a single bit set in the position of the most significant set bit of this [Long](-long/index#kotlin.Long) number, or zero, if this number is zero. ``` fun Long.takeHighestOneBit(): Long ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [takeIf](take-if) Returns `this` value if it satisfies the given [predicate](take-if#kotlin%24takeIf(kotlin.takeIf.T,%20kotlin.Function1((kotlin.takeIf.T,%20kotlin.Boolean)))/predicate) or `null`, if it doesn't. ``` fun <T> T.takeIf(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeLowestOneBit](take-lowest-one-bit) Returns a number having a single bit set in the position of the least significant set bit of this [Byte](-byte/index#kotlin.Byte) number, or zero, if this number is zero. ``` fun Byte.takeLowestOneBit(): Byte ``` Returns a number having a single bit set in the position of the least significant set bit of this [Short](-short/index#kotlin.Short) number, or zero, if this number is zero. ``` fun Short.takeLowestOneBit(): Short ``` Returns a number having a single bit set in the position of the least significant set bit of this [UInt](-u-int/index) number, or zero, if this number is zero. ``` fun UInt.takeLowestOneBit(): UInt ``` Returns a number having a single bit set in the position of the least significant set bit of this [ULong](-u-long/index) number, or zero, if this number is zero. ``` fun ULong.takeLowestOneBit(): ULong ``` Returns a number having a single bit set in the position of the least significant set bit of this [UByte](-u-byte/index) number, or zero, if this number is zero. ``` fun UByte.takeLowestOneBit(): UByte ``` Returns a number having a single bit set in the position of the least significant set bit of this [UShort](-u-short/index) number, or zero, if this number is zero. ``` fun UShort.takeLowestOneBit(): UShort ``` Returns a number having a single bit set in the position of the least significant set bit of this [Int](-int/index#kotlin.Int) number, or zero, if this number is zero. ``` fun Int.takeLowestOneBit(): Int ``` Returns a number having a single bit set in the position of the least significant set bit of this [Long](-long/index#kotlin.Long) number, or zero, if this number is zero. ``` fun Long.takeLowestOneBit(): Long ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [takeUnless](take-unless) Returns `this` value if it *does not* satisfy the given [predicate](take-unless#kotlin%24takeUnless(kotlin.takeUnless.T,%20kotlin.Function1((kotlin.takeUnless.T,%20kotlin.Boolean)))/predicate) or `null`, if it does. ``` fun <T> T.takeUnless(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <to> Creates a tuple of type [Pair](-pair/index) from this and [that](to#kotlin%24to(kotlin.to.A,%20kotlin.to.B)/that). ``` infix fun <A, B> A.to(that: B): Pair<A, B> ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](to-big-decimal) Returns the value of this [Int](-int/index#kotlin.Int) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Int.toBigDecimal(): BigDecimal ``` ``` fun Int.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Long](-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 ``` Returns the value of this [Float](-float/index#kotlin.Float) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Float.toBigDecimal(): BigDecimal ``` ``` fun Float.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Double](-double/index#kotlin.Double) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Double.toBigDecimal(): BigDecimal ``` ``` fun Double.toBigDecimal(mathContext: MathContext): BigDecimal ``` **Platform and version requirements:** JVM (1.2) #### [toBigInteger](to-big-integer) Returns the value of this [Int](-int/index#kotlin.Int) number as a [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html). ``` fun Int.toBigInteger(): BigInteger ``` Returns the value of this [Long](-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:** JVM (1.2), JS (1.2), Native (1.2) #### [toBits](to-bits) Returns a bit representation of the specified floating-point value as [Long](-long/index#kotlin.Long) according to the IEEE 754 floating-point "double format" bit layout. ``` fun Double.toBits(): Long ``` Returns a bit representation of the specified floating-point value as [Int](-int/index#kotlin.Int) according to the IEEE 754 floating-point "single format" bit layout. ``` fun Float.toBits(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [TODO](-t-o-d-o) Always throws [NotImplementedError](-not-implemented-error/index) stating that operation is not implemented. ``` fun TODO(): Nothing ``` ``` fun TODO(reason: String): Nothing ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](to-list) Converts this pair into a list. ``` fun <T> Pair<T, T>.toList(): List<T> ``` Converts this triple into a list. ``` fun <T> Triple<T, T, T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [toRawBits](to-raw-bits) Returns a bit representation of the specified floating-point value as [Long](-long/index#kotlin.Long) according to the IEEE 754 floating-point "double format" bit layout, preserving `NaN` values exact layout. ``` fun Double.toRawBits(): Long ``` Returns a bit representation of the specified floating-point value as [Int](-int/index#kotlin.Int) according to the IEEE 754 floating-point "single format" bit layout, preserving `NaN` values exact layout. ``` fun Float.toRawBits(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string representation of the object. Can be called with a null receiver, in which case it returns the string "null". ``` fun Any?.toString(): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](to-u-byte) Converts this [Byte](-byte/index#kotlin.Byte) value to [UByte](-u-byte/index). ``` fun Byte.toUByte(): UByte ``` Converts this [Short](-short/index#kotlin.Short) value to [UByte](-u-byte/index). ``` fun Short.toUByte(): UByte ``` Converts this [Int](-int/index#kotlin.Int) value to [UByte](-u-byte/index). ``` fun Int.toUByte(): UByte ``` Converts this [Long](-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 [Byte](-byte/index#kotlin.Byte) value to [UInt](-u-int/index). ``` fun Byte.toUInt(): UInt ``` Converts this [Short](-short/index#kotlin.Short) value to [UInt](-u-int/index). ``` fun Short.toUInt(): UInt ``` Converts this [Int](-int/index#kotlin.Int) value to [UInt](-u-int/index). ``` fun Int.toUInt(): UInt ``` Converts this [Long](-long/index#kotlin.Long) value to [UInt](-u-int/index). ``` fun Long.toUInt(): UInt ``` Converts this [Float](-float/index#kotlin.Float) value to [UInt](-u-int/index). ``` fun Float.toUInt(): UInt ``` Converts this [Double](-double/index#kotlin.Double) value to [UInt](-u-int/index). ``` fun Double.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](to-u-long) Converts this [Byte](-byte/index#kotlin.Byte) value to [ULong](-u-long/index). ``` fun Byte.toULong(): ULong ``` Converts this [Short](-short/index#kotlin.Short) value to [ULong](-u-long/index). ``` fun Short.toULong(): ULong ``` Converts this [Int](-int/index#kotlin.Int) value to [ULong](-u-long/index). ``` fun Int.toULong(): ULong ``` Converts this [Long](-long/index#kotlin.Long) value to [ULong](-u-long/index). ``` fun Long.toULong(): ULong ``` Converts this [Float](-float/index#kotlin.Float) value to [ULong](-u-long/index). ``` fun Float.toULong(): ULong ``` Converts this [Double](-double/index#kotlin.Double) value to [ULong](-u-long/index). ``` fun Double.toULong(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](to-u-short) Converts this [Byte](-byte/index#kotlin.Byte) value to [UShort](-u-short/index). ``` fun Byte.toUShort(): UShort ``` Converts this [Short](-short/index#kotlin.Short) value to [UShort](-u-short/index). ``` fun Short.toUShort(): UShort ``` Converts this [Int](-int/index#kotlin.Int) value to [UShort](-u-short/index). ``` fun Int.toUShort(): UShort ``` Converts this [Long](-long/index#kotlin.Long) value to [UShort](-u-short/index). ``` fun Long.toUShort(): UShort ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UByteArray](-u-byte-array) Creates a new array of the specified [size](-u-byte-array#kotlin%24UByteArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/size), where each element is calculated by calling the specified [init](-u-byte-array#kotlin%24UByteArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/init) function. ``` fun UByteArray(size: Int, init: (Int) -> UByte): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ubyteArrayOf](ubyte-array-of) ``` fun ubyteArrayOf(vararg elements: UByte): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UIntArray](-u-int-array) Creates a new array of the specified [size](-u-int-array#kotlin%24UIntArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/size), where each element is calculated by calling the specified [init](-u-int-array#kotlin%24UIntArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/init) function. ``` fun UIntArray(size: Int, init: (Int) -> UInt): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [uintArrayOf](uint-array-of) ``` fun uintArrayOf(vararg elements: UInt): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ULongArray](-u-long-array) Creates a new array of the specified [size](-u-long-array#kotlin%24ULongArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/size), where each element is calculated by calling the specified [init](-u-long-array#kotlin%24ULongArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/init) function. ``` fun ULongArray(size: Int, init: (Int) -> ULong): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ulongArrayOf](ulong-array-of) ``` fun ulongArrayOf(vararg elements: ULong): ULongArray ``` **Platform and version requirements:** JVM (1.2), JRE7 (1.2) #### <use> Executes the given [block](use#kotlin%24use(kotlin.use.T,%20kotlin.Function1((kotlin.use.T,%20kotlin.use.R)))/block) function on this resource and then closes it down correctly whether an exception is thrown or not. ``` fun <T : AutoCloseable?, R> T.use(block: (T) -> R): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UShortArray](-u-short-array) Creates a new array of the specified [size](-u-short-array#kotlin%24UShortArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/size), where each element is calculated by calling the specified [init](-u-short-array#kotlin%24UShortArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/init) function. ``` fun UShortArray(     size: Int,     init: (Int) -> UShort ): UShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ushortArrayOf](ushort-array-of) ``` fun ushortArrayOf(vararg elements: UShort): UShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <with> Calls the specified function [block](with#kotlin%24with(kotlin.with.T,%20kotlin.Function1((kotlin.with.T,%20kotlin.with.R)))/block) with the given [receiver](with#kotlin%24with(kotlin.with.T,%20kotlin.Function1((kotlin.with.T,%20kotlin.with.R)))/receiver) as its receiver and returns its result. ``` fun <T, R> with(receiver: T, block: T.() -> R): R ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [fromBits](from-bits) Returns the [Double](-double/index#kotlin.Double) value corresponding to a given bit representation. ``` fun Double.Companion.fromBits(bits: Long): Double ``` Returns the [Float](-float/index#kotlin.Float) value corresponding to a given bit representation. ``` fun Float.Companion.fromBits(bits: Int): Float ```
programming_docs
kotlin mapCatching mapCatching =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [mapCatching](map-catching) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T> Result<T>.mapCatching(     transform: (value: T) -> R ): Result<R> ``` Returns the encapsulated result of the given [transform](map-catching#kotlin%24mapCatching(kotlin.Result((kotlin.mapCatching.T)),%20kotlin.Function1((kotlin.mapCatching.T,%20kotlin.mapCatching.R)))/transform) function applied to the encapsulated value if this instance represents [success](-result/is-success) or the original encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). This function catches any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [transform](map-catching#kotlin%24mapCatching(kotlin.Result((kotlin.mapCatching.T)),%20kotlin.Function1((kotlin.mapCatching.T,%20kotlin.mapCatching.R)))/transform) function and encapsulates it as a failure. See <map> for an alternative that rethrows exceptions from `transform` function. kotlin setValue setValue ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [setValue](set-value) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` operator fun <V> KMutableProperty0<V>.setValue(     thisRef: Any?,     property: KProperty<*>,     value: V) ``` An extension operator that allows delegating a mutable property of type [V](set-value#V) to a property reference to a mutable property of the same type [V](set-value#V). **Receiver** A property reference to a mutable property of type [V](set-value#V). The reference is without a receiver, i.e. it either references a top-level property or has the receiver bound to it. Example: ``` class Login(val username: String, var incorrectAttemptCounter: Int = 0) val defaultLogin = Login("Admin") var defaultLoginAttempts by defaultLogin::incorrectAttemptCounter // equivalent to var defaultLoginAttempts: Int get() = defaultLogin.incorrectAttemptCounter set(value) { defaultLogin.incorrectAttemptCounter = value } ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` operator fun <T, V> KMutableProperty1<T, V>.setValue(     thisRef: T,     property: KProperty<*>,     value: V) ``` An extension operator that allows delegating a mutable member or extension property of type [V](set-value#V) to a property reference to a member or extension mutable property of the same type [V](set-value#V). **Receiver** A property reference to a read-only or mutable property of type [V](set-value#V) or its subtype. The reference has an unbound receiver of type [T](set-value#T). Example: ``` class Login(val username: String, var incorrectAttemptCounter: Int) var Login.attempts by Login::incorrectAttemptCounter // equivalent to var Login.attempts: Int get() = this.incorrectAttemptCounter set(value) { this.incorrectAttemptCounter = value } ``` kotlin enumValueOf enumValueOf =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [enumValueOf](enum-value-of) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.3) ``` fun <reified T : Enum<T>> enumValueOf(name: String): T ``` Returns an enum entry with specified name. kotlin byteArrayOf byteArrayOf =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [byteArrayOf](byte-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun byteArrayOf(vararg elements: Byte): ByteArray ``` Returns an array containing the specified [Byte](-byte/index#kotlin.Byte) numbers. kotlin let let === [kotlin-stdlib](../../../../../index) / [kotlin](index) / <let> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T, R> T.let(block: (T) -> R): R ``` Calls the specified function [block](let#kotlin%24let(kotlin.let.T,%20kotlin.Function1((kotlin.let.T,%20kotlin.let.R)))/block) with `this` value as its argument and returns its result. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#let). kotlin addSuppressed addSuppressed ============= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [addSuppressed](add-suppressed) **Platform and version requirements:** JVM (1.1), JS (1.4), Native (1.4) ``` fun Throwable.addSuppressed(exception: Throwable) ``` ##### For Common, JVM When supported by the platform, adds the specified exception to the list of exceptions that were suppressed in order to deliver this exception. ##### For JS Adds the specified exception to the list of exceptions that were suppressed in order to deliver this exception. ##### For Native Adds the specified exception to the list of exceptions that were suppressed in order to deliver this exception. Legacy MM: does nothing if this [Throwable](-throwable/index#kotlin.Throwable) is frozen. kotlin getOrDefault getOrDefault ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [getOrDefault](get-or-default) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <R, T : R> Result<T>.getOrDefault(defaultValue: R): R ``` Returns the encapsulated value if this instance represents [success](-result/is-success) or the [defaultValue](get-or-default#kotlin%24getOrDefault(kotlin.Result((kotlin.getOrDefault.T)),%20kotlin.getOrDefault.R)/defaultValue) if it is [failure](-result/is-failure). This function is a shorthand for `getOrElse { defaultValue }` (see [getOrElse](get-or-else)). kotlin invoke invoke ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <invoke> **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` operator fun <T, R> DeepRecursiveFunction<T, R>.invoke(     value: T ): R ``` Initiates a call to this deep recursive function, forming a root of the call tree. This operator should not be used from inside of [DeepRecursiveScope](-deep-recursive-scope/index) as it uses the call stack slot for initial recursive invocation. From inside of [DeepRecursiveScope](-deep-recursive-scope/index) use [callRecursive](-deep-recursive-scope/call-recursive). kotlin require require ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / <require> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun require(value: Boolean) ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) if the [value](require#kotlin%24require(kotlin.Boolean)/value) is false. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun getIndices(count: Int): List<Int> { require(count >= 0) { "Count must be non-negative, was $count" } // ... return List(count) { it + 1 } } // getIndices(-1) // will fail with IllegalArgumentException println(getIndices(3)) // [1, 2, 3] //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun require(value: Boolean, lazyMessage: () -> Any) ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) with the result of calling [lazyMessage](require#kotlin%24require(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](require#kotlin%24require(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun getIndices(count: Int): List<Int> { require(count >= 0) { "Count must be non-negative, was $count" } // ... return List(count) { it + 1 } } // getIndices(-1) // will fail with IllegalArgumentException println(getIndices(3)) // [1, 2, 3] //sampleEnd } ``` kotlin recover recover ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / <recover> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T : R> Result<T>.recover(     transform: (exception: Throwable) -> R ): Result<R> ``` Returns the encapsulated result of the given [transform](recover#kotlin%24recover(kotlin.Result((kotlin.recover.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recover.R)))/transform) function applied to the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure) or the original encapsulated value if it is [success](-result/is-success). Note, that this function rethrows any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [transform](recover#kotlin%24recover(kotlin.Result((kotlin.recover.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recover.R)))/transform) function. See [recoverCatching](recover-catching) for an alternative that encapsulates exceptions. kotlin UByteArray UByteArray ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [UByteArray](-u-byte-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline fun UByteArray(     size: Int,     init: (Int) -> UByte ): UByteArray ``` Creates a new array of the specified [size](-u-byte-array#kotlin%24UByteArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/size), where each element is calculated by calling the specified [init](-u-byte-array#kotlin%24UByteArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/init) function. The function [init](-u-byte-array#kotlin%24UByteArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/init) is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. kotlin doubleArrayOf doubleArrayOf ============= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [doubleArrayOf](double-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun doubleArrayOf(vararg elements: Double): DoubleArray ``` Returns an array containing the specified [Double](-double/index#kotlin.Double) numbers. kotlin stackTrace stackTrace ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [stackTrace](stack-trace) **Platform and version requirements:** JVM (1.0) ``` val Throwable.stackTrace: Array<StackTraceElement> ``` Returns an array of stack trace elements representing the stack trace pertaining to this throwable. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` infix fun <T> Comparable<T>.compareTo(other: T): Int ``` 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). This function delegates to [Comparable.compareTo](-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)) and allows to call it in infix form. kotlin repeat repeat ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <repeat> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun repeat(times: Int, action: (Int) -> Unit) ``` Executes the given function [action](repeat#kotlin%24repeat(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/action) specified number of [times](repeat#kotlin%24repeat(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/times). A zero-based index of current iteration is passed as a parameter to [action](repeat#kotlin%24repeat(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/action). ``` fun main(args: Array<String>) { //sampleStart // greets three times repeat(3) { println("Hello") } // greets with an index repeat(3) { index -> println("Hello with index $index") } repeat(0) { error("We should not get here!") } //sampleEnd } ``` kotlin apply apply ===== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <apply> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T> T.apply(block: T.() -> Unit): T ``` Calls the specified function [block](apply#kotlin%24apply(kotlin.apply.T,%20kotlin.Function1((kotlin.apply.T,%20kotlin.Unit)))/block) with `this` value as its receiver and returns `this` value. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#apply). kotlin isInitialized isInitialized ============= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [isInitialized](is-initialized) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` inline val KProperty0<*>.isInitialized: Boolean ``` Returns `true` if this lateinit property has been assigned a value, and `false` otherwise. Cannot be used in an inline function, to avoid binary compatibility issues. kotlin ubyteArrayOf ubyteArrayOf ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [ubyteArrayOf](ubyte-array-of) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ubyteArrayOf(     vararg elements: UByte ): UByteArray ``` kotlin assert assert ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <assert> **Platform and version requirements:** JVM (1.0), Native (1.0) ``` fun assert(value: Boolean) ``` ##### For JVM Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) if the [value](assert#kotlin%24assert(kotlin.Boolean)/value) is false and runtime assertions have been enabled on the JVM using the *-ea* JVM option. ##### For Native Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) if the [value](assert#kotlin%24assert(kotlin.Boolean)/value) is false and runtime assertions have been enabled during compilation. **Platform and version requirements:** JVM (1.0), Native (1.0) ``` inline fun assert(value: Boolean, lazyMessage: () -> Any) ``` ##### For JVM Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) calculated by [lazyMessage](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false and runtime assertions have been enabled on the JVM using the *-ea* JVM option. ##### For Native Throws an [AssertionError](-assertion-error/index#kotlin.AssertionError) calculated by [lazyMessage](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](assert#kotlin%24assert(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false and runtime assertions have been enabled during compilation. kotlin countLeadingZeroBits countLeadingZeroBits ==================== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [countLeadingZeroBits](count-leading-zero-bits) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Int.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Int](-int/index#kotlin.Int) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Long.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Long](-long/index#kotlin.Long) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Byte.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Short.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [Short](-short/index#kotlin.Short) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UInt](-u-int/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [ULong](-u-long/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UByte](-u-byte/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.countLeadingZeroBits(): Int ``` Counts the number of consecutive most significant bits that are zero in the binary representation of this [UShort](-u-short/index) number. kotlin intArrayOf intArrayOf ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [intArrayOf](int-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun intArrayOf(vararg elements: Int): IntArray ``` Returns an array containing the specified [Int](-int/index#kotlin.Int) numbers. kotlin getValue getValue ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [getValue](get-value) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` operator fun <V> KProperty0<V>.getValue(     thisRef: Any?,     property: KProperty<*> ): V ``` An extension operator that allows delegating a read-only property of type [V](get-value#V) to a property reference to a property of type [V](get-value#V) or its subtype. **Receiver** A property reference to a read-only or mutable property of type [V](get-value#V) or its subtype. The reference is without a receiver, i.e. it either references a top-level property or has the receiver bound to it. Example: ``` class Login(val username: String) val defaultLogin = Login("Admin") val defaultUsername by defaultLogin::username // equivalent to val defaultUserName get() = defaultLogin.username ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` operator fun <T, V> KProperty1<T, V>.getValue(     thisRef: T,     property: KProperty<*> ): V ``` An extension operator that allows delegating a read-only member or extension property of type [V](get-value#V) to a property reference to a member or extension property of type [V](get-value#V) or its subtype. **Receiver** A property reference to a read-only or mutable property of type [V](get-value#V) or its subtype. The reference has an unbound receiver of type [T](get-value#T). Example: ``` class Login(val username: String) val Login.user by Login::username // equivalent to val Login.user get() = this.username ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun <T> Lazy<T>.getValue(     thisRef: Any?,     property: KProperty<*> ): T ``` An extension to delegate a read-only property of type [T](get-value#T) to an instance of [Lazy](-lazy/index). This extension allows to use instances of Lazy for property delegation: `val property: String by lazy { initializer }`
programming_docs
kotlin Char Char ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [Char](-char) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char(code: Int): Char ``` Creates a Char with the specified [code](-char#kotlin%24Char(kotlin.Int)/code), or throws an exception if the [code](-char#kotlin%24Char(kotlin.Int)/code) is out of `Char.MIN_VALUE.code..Char.MAX_VALUE.code`. If the program that calls this function is written in a way that only valid [code](-char#kotlin%24Char(kotlin.Int)/code) is passed as the argument, using the overload that takes a [UShort](-u-short/index) argument is preferable (`Char(intValue.toUShort())`). That overload doesn't check validity of the argument, and may improve program performance when the function is called routinely inside a loop. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val codes = listOf(48, 65, 122, 946) println(codes.map { Char(it) }) // [0, A, z, β] println(codes.map { Char(it.toUShort()) }) // [0, A, z, β] // Char(-1) // will fail println(Char(UShort.MIN_VALUE)) // \u0000 // Char(1_000_000) // will fail println(Char(UShort.MAX_VALUE)) // \uFFFF //sampleEnd } ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Char(code: UShort): Char ``` Creates a Char with the specified [code](-char#kotlin%24Char(kotlin.UShort)/code). ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val codes = listOf(48, 65, 122, 946) println(codes.map { Char(it) }) // [0, A, z, β] println(codes.map { Char(it.toUShort()) }) // [0, A, z, β] // Char(-1) // will fail println(Char(UShort.MIN_VALUE)) // \u0000 // Char(1_000_000) // will fail println(Char(UShort.MAX_VALUE)) // \uFFFF //sampleEnd } ``` kotlin to to == [kotlin-stdlib](../../../../../index) / [kotlin](index) / <to> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun <A, B> A.to(that: B): Pair<A, B> ``` Creates a tuple of type [Pair](-pair/index) from this and [that](to#kotlin%24to(kotlin.to.A,%20kotlin.to.B)/that). This can be useful for creating [Map](../kotlin.collections/-map/index#kotlin.collections.Map) literals with less noise, for example: ``` 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 } ``` kotlin suspend suspend ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / <suspend> **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` inline fun <R> suspend(     noinline block: suspend () -> R ): suspend () -> R ``` kotlin check check ===== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <check> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun check(value: Boolean) ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) if the [value](check#kotlin%24check(kotlin.Boolean)/value) is false. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart var someState: String? = null fun getStateValue(): String { val state = checkNotNull(someState) { "State must be set beforehand" } check(state.isNotEmpty()) { "State must be non-empty" } // ... return state } // getStateValue() // will fail with IllegalStateException someState = "" // getStateValue() // will fail with IllegalStateException someState = "non-empty-state" println(getStateValue()) // non-empty-state //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun check(value: Boolean, lazyMessage: () -> Any) ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the result of calling [lazyMessage](check#kotlin%24check(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](check#kotlin%24check(kotlin.Boolean,%20kotlin.Function0((kotlin.Any)))/value) is false. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart var someState: String? = null fun getStateValue(): String { val state = checkNotNull(someState) { "State must be set beforehand" } check(state.isNotEmpty()) { "State must be non-empty" } // ... return state } // getStateValue() // will fail with IllegalStateException someState = "" // getStateValue() // will fail with IllegalStateException someState = "non-empty-state" println(getStateValue()) // non-empty-state //sampleEnd } ``` kotlin use use === [kotlin-stdlib](../../../../../index) / [kotlin](index) / <use> **Platform and version requirements:** JVM (1.2), JRE7 (1.2) ``` inline fun <T : AutoCloseable?, R> T.use(block: (T) -> R): R ``` Executes the given [block](use#kotlin%24use(kotlin.use.T,%20kotlin.Function1((kotlin.use.T,%20kotlin.use.R)))/block) function on this resource and then closes it down correctly whether an exception is thrown or not. In case if the resource is being closed due to an exception occurred in [block](use#kotlin%24use(kotlin.use.T,%20kotlin.Function1((kotlin.use.T,%20kotlin.use.R)))/block), and the closing also fails with an exception, the latter is added to the [suppressed](https://docs.oracle.com/javase/8/docs/api/java/lang/Throwable.html#addSuppressed-java.lang.Throwable-) exceptions of the former. Parameters ---------- `block` - a function to process this [AutoCloseable](https://docs.oracle.com/javase/8/docs/api/java/lang/AutoCloseable.html) resource. **Return** the result of [block](use#kotlin%24use(kotlin.use.T,%20kotlin.Function1((kotlin.use.T,%20kotlin.use.R)))/block) function invoked on this resource. kotlin takeIf takeIf ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [takeIf](take-if) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T> T.takeIf(predicate: (T) -> Boolean): T? ``` Returns `this` value if it satisfies the given [predicate](take-if#kotlin%24takeIf(kotlin.takeIf.T,%20kotlin.Function1((kotlin.takeIf.T,%20kotlin.Boolean)))/predicate) or `null`, if it doesn't. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#takeif-and-takeunless). kotlin emptyArray emptyArray ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [emptyArray](empty-array) **Platform and version requirements:** JVM (1.0) ``` fun <reified T> emptyArray(): Array<T> ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun <T> emptyArray(): Array<T> ``` Returns an empty array of the specified type [T](empty-array#T). kotlin stackTraceToString stackTraceToString ================== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [stackTraceToString](stack-trace-to-string) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Throwable.stackTraceToString(): String ``` Returns the detailed description of this throwable with its stack trace. The detailed description includes: * the short description (see [Throwable.toString](-any/to-string#kotlin.Any%24toString())) of this throwable; * the complete stack trace; * detailed descriptions of the exceptions that were suppressed in order to deliver this exception; * the detailed description of each throwable in the [Throwable.cause](-throwable/cause#kotlin.Throwable%24cause) chain. kotlin takeUnless takeUnless ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [takeUnless](take-unless) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T> T.takeUnless(predicate: (T) -> Boolean): T? ``` Returns `this` value if it *does not* satisfy the given [predicate](take-unless#kotlin%24takeUnless(kotlin.takeUnless.T,%20kotlin.Function1((kotlin.takeUnless.T,%20kotlin.Boolean)))/predicate) or `null`, if it does. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#takeif-and-takeunless). kotlin getOrThrow getOrThrow ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [getOrThrow](get-or-throw) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun <T> Result<T>.getOrThrow(): T ``` Returns the encapsulated value if this instance represents [success](-result/is-success) or throws the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). This function is a shorthand for `getOrElse { throw it }` (see [getOrElse](get-or-else)). kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` fun Any?.hashCode(): Int ``` Returns a hash code value for the object or zero if the object is `null`. **See Also** [Any.hashCode](-any/hash-code#kotlin.Any%24hashCode()) kotlin getOrElse getOrElse ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [getOrElse](get-or-else) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T : R> Result<T>.getOrElse(     onFailure: (exception: Throwable) -> R ): R ``` Returns the encapsulated value if this instance represents [success](-result/is-success) or the result of [onFailure](get-or-else#kotlin%24getOrElse(kotlin.Result((kotlin.getOrElse.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.getOrElse.R)))/onFailure) function for the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). Note, that this function rethrows any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [onFailure](get-or-else#kotlin%24getOrElse(kotlin.Result((kotlin.getOrElse.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.getOrElse.R)))/onFailure) function. This function is a shorthand for `fold(onSuccess = { it }, onFailure = onFailure)` (see <fold>). kotlin floatArrayOf floatArrayOf ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [floatArrayOf](float-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun floatArrayOf(vararg elements: Float): FloatArray ``` Returns an array containing the specified [Float](-float/index#kotlin.Float) numbers. kotlin toBits toBits ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toBits](to-bits) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.toBits(): Long ``` Returns a bit representation of the specified floating-point value as [Long](-long/index#kotlin.Long) according to the IEEE 754 floating-point "double format" bit layout. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Float.toBits(): Int ``` ##### For Common, JVM, Native Returns a bit representation of the specified floating-point value as [Int](-int/index#kotlin.Int) according to the IEEE 754 floating-point "single format" bit layout. ##### For JS Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout. Note that in Kotlin/JS Float range is wider than "single format" bit layout can represent, so some Float values may overflow, underflow or loose their accuracy after conversion to bits and back. kotlin printStackTrace printStackTrace =============== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [printStackTrace](print-stack-trace) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Throwable.printStackTrace() ``` ##### For Common Prints the [detailed description](stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output or standard error output. ##### For JVM Prints the [detailed description](stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard error output. ##### For JS Prints the [detailed description](stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to console error output. ##### For Native Prints the [detailed description](stack-trace-to-string#kotlin%24stackTraceToString(kotlin.Throwable)) of this throwable to the standard output. **Platform and version requirements:** JVM (1.0) ``` fun Throwable.printStackTrace(writer: PrintWriter) ``` 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). **Platform and version requirements:** JVM (1.0) ``` fun Throwable.printStackTrace(stream: PrintStream) ``` 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). kotlin countOneBits countOneBits ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [countOneBits](count-one-bits) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Int.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Int](-int/index#kotlin.Int) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Long.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Long](-long/index#kotlin.Long) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Byte.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Short.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [Short](-short/index#kotlin.Short) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UInt](-u-int/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [ULong](-u-long/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UByte](-u-byte/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.countOneBits(): Int ``` Counts the number of set bits in the binary representation of this [UShort](-u-short/index) number. kotlin ulongArrayOf ulongArrayOf ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [ulongArrayOf](ulong-array-of) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ulongArrayOf(     vararg elements: ULong ): ULongArray ``` kotlin recoverCatching recoverCatching =============== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [recoverCatching](recover-catching) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T : R> Result<T>.recoverCatching(     transform: (exception: Throwable) -> R ): Result<R> ``` Returns the encapsulated result of the given [transform](recover-catching#kotlin%24recoverCatching(kotlin.Result((kotlin.recoverCatching.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recoverCatching.R)))/transform) function applied to the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure) or the original encapsulated value if it is [success](-result/is-success). This function catches any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [transform](recover-catching#kotlin%24recoverCatching(kotlin.Result((kotlin.recoverCatching.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recoverCatching.R)))/transform) function and encapsulates it as a failure. See <recover> for an alternative that rethrows exceptions. kotlin lazyOf lazyOf ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [lazyOf](lazy-of) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> lazyOf(value: T): Lazy<T> ``` Creates a new instance of the [Lazy](-lazy/index) that is already initialized with the specified [value](lazy-of#kotlin%24lazyOf(kotlin.lazyOf.T)/value). kotlin toString toString ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun Any?.toString(): String ``` Returns a string representation of the object. Can be called with a null receiver, in which case it returns the string "null". kotlin lazy lazy ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <lazy> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> lazy(initializer: () -> T): Lazy<T> ``` ##### For JVM, Native Creates a new instance of the Lazy that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.Function0((kotlin.lazy.T)))/initializer) and the default thread-safety mode LazyThreadSafetyMode.SYNCHRONIZED. If the initialization of a value throws an exception, it will attempt to reinitialize the value at next access. Note that the returned instance uses itself to synchronize on. Do not synchronize from external code on the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future. ##### For JS Creates a new instance of the Lazy that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.Function0((kotlin.lazy.T)))/initializer). **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> lazy(     mode: LazyThreadSafetyMode,     initializer: () -> T ): Lazy<T> ``` ##### For Common, JS Creates a new instance of the [Lazy](-lazy/index) that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.LazyThreadSafetyMode,%20kotlin.Function0((kotlin.lazy.T)))/initializer). The [mode](lazy#kotlin%24lazy(kotlin.LazyThreadSafetyMode,%20kotlin.Function0((kotlin.lazy.T)))/mode) parameter is ignored. ##### For JVM, Native Creates a new instance of the Lazy that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.LazyThreadSafetyMode,%20kotlin.Function0((kotlin.lazy.T)))/initializer) and thread-safety [mode](lazy#kotlin%24lazy(kotlin.LazyThreadSafetyMode,%20kotlin.Function0((kotlin.lazy.T)))/mode). If the initialization of a value throws an exception, it will attempt to reinitialize the value at next access. Note that when the LazyThreadSafetyMode.SYNCHRONIZED mode is specified the returned instance uses itself to synchronize on. Do not synchronize from external code on the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T> lazy(lock: Any?, initializer: () -> T): Lazy<T> ``` ##### For Common, JS Creates a new instance of the [Lazy](-lazy/index) that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.Any?,%20kotlin.Function0((kotlin.lazy.T)))/initializer). The [lock](lazy#kotlin%24lazy(kotlin.Any?,%20kotlin.Function0((kotlin.lazy.T)))/lock) parameter is ignored. ##### For JVM, Native Creates a new instance of the Lazy that uses the specified initialization function [initializer](lazy#kotlin%24lazy(kotlin.Any?,%20kotlin.Function0((kotlin.lazy.T)))/initializer) and the default thread-safety mode LazyThreadSafetyMode.SYNCHRONIZED. If the initialization of a value throws an exception, it will attempt to reinitialize the value at next access. The returned instance uses the specified [lock](lazy#kotlin%24lazy(kotlin.Any?,%20kotlin.Function0((kotlin.lazy.T)))/lock) object to synchronize on. When the [lock](lazy#kotlin%24lazy(kotlin.Any?,%20kotlin.Function0((kotlin.lazy.T)))/lock) is not specified the instance uses itself to synchronize on, in this case do not synchronize from external code on the returned instance as it may cause accidental deadlock. Also this behavior can be changed in the future.
programming_docs
kotlin toUInt toUInt ====== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.toUInt(): UInt ``` Converts this [Byte](-byte/index#kotlin.Byte) value to [UInt](-u-int/index). If this value is positive, the resulting `UInt` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `UInt` value are the same as the bits of this `Byte` value, whereas the most significant 24 bits are filled with the sign bit of this value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Short.toUInt(): UInt ``` Converts this [Short](-short/index#kotlin.Short) value to [UInt](-u-int/index). If this value is positive, the resulting `UInt` value represents the same numerical value as this `Short`. The least significant 16 bits of the resulting `UInt` value are the same as the bits of this `Short` value, whereas the most significant 16 bits are filled with the sign bit of this value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.toUInt(): UInt ``` Converts this [Int](-int/index#kotlin.Int) value to [UInt](-u-int/index). If this value is positive, the resulting `UInt` value represents the same numerical value as this `Int`. The resulting `UInt` value has the same binary representation as this `Int` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Long.toUInt(): UInt ``` Converts this [Long](-long/index#kotlin.Long) value to [UInt](-u-int/index). If this value is positive and less than or equals to [UInt.MAX\_VALUE](-u-int/-m-a-x_-v-a-l-u-e), the resulting `UInt` value represents the same numerical value as this `Long`. The resulting `UInt` value is represented by the least significant 32 bits of this `Long` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Float.toUInt(): UInt ``` Converts this [Float](-float/index#kotlin.Float) value to [UInt](-u-int/index). The fractional part, if any, is rounded down towards zero. Returns zero if this `Float` value is negative or `NaN`, [UInt.MAX\_VALUE](-u-int/-m-a-x_-v-a-l-u-e) if it's bigger than `UInt.MAX_VALUE`. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Double.toUInt(): UInt ``` Converts this [Double](-double/index#kotlin.Double) value to [UInt](-u-int/index). The fractional part, if any, is rounded down towards zero. Returns zero if this `Double` value is negative or `NaN`, [UInt.MAX\_VALUE](-u-int/-m-a-x_-v-a-l-u-e) if it's bigger than `UInt.MAX_VALUE`. kotlin toBigInteger toBigInteger ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toBigInteger](to-big-integer) **Platform and version requirements:** JVM (1.2) ``` fun Int.toBigInteger(): BigInteger ``` Returns the value of this [Int](-int/index#kotlin.Int) number as a [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html). **Platform and version requirements:** JVM (1.2) ``` fun Long.toBigInteger(): BigInteger ``` Returns the value of this [Long](-long/index#kotlin.Long) number as a [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html). kotlin requireNotNull requireNotNull ============== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [requireNotNull](require-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> requireNotNull(value: T?): T ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) if the [value](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?)/value) is null. Otherwise returns the not null value. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T : Any> requireNotNull(     value: T?,     lazyMessage: () -> Any ): T ``` Throws an [IllegalArgumentException](-illegal-argument-exception/index#kotlin.IllegalArgumentException) with the result of calling [lazyMessage](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](require-not-null#kotlin%24requireNotNull(kotlin.requireNotNull.T?,%20kotlin.Function0((kotlin.Any)))/value) is null. Otherwise returns the not null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart fun printRequiredParam(params: Map<String, String?>) { val required: String = requireNotNull(params["required"]) { "Required value must be non-null" } // returns a non-null value println(required) // ... } fun printRequiredParamByUpperCase(params: Map<String, String?>) { val requiredParam: String? = params["required"] requireNotNull(requiredParam) { "Required value must be non-null" } // now requiredParam is smartcast to String so that it is unnecessary to use the safe call(?.) println(requiredParam.uppercase()) } val params: MutableMap<String, String?> = mutableMapOf("required" to null) // printRequiredParam(params) // will fail with IllegalArgumentException // printRequiredParamByUpperCase(params) // will fail with IllegalArgumentException params["required"] = "non-empty-param" printRequiredParam(params) // prints "non-empty-param" printRequiredParamByUpperCase(params) // prints "NON-EMPTY-PARAM" //sampleEnd } ``` kotlin booleanArrayOf booleanArrayOf ============== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [booleanArrayOf](boolean-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun booleanArrayOf(vararg elements: Boolean): BooleanArray ``` Returns an array containing the specified boolean values. kotlin fromBits fromBits ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [fromBits](from-bits) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.Companion.fromBits(bits: Long): Double ``` Returns the [Double](-double/index#kotlin.Double) value corresponding to a given bit representation. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Float.Companion.fromBits(bits: Int): Float ``` Returns the [Float](-float/index#kotlin.Float) value corresponding to a given bit representation. kotlin Function Function ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [Function](-function) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface Function<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. Extension Functions ------------------- **Platform and version requirements:** JVM (1.0) #### [reflect](../kotlin.reflect.jvm/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>? ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KFunction](../kotlin.reflect/-k-function/index) Represents a function with introspection capabilities. ``` interface KFunction<out R> : KCallable<R>, Function<R> ``` kotlin checkNotNull checkNotNull ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [checkNotNull](check-not-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun <T : Any> checkNotNull(value: T?): T ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) if the [value](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?)/value) is null. Otherwise returns the not null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart var someState: String? = null fun getStateValue(): String { val state = checkNotNull(someState) { "State must be set beforehand" } check(state.isNotEmpty()) { "State must be non-empty" } // ... return state } // getStateValue() // will fail with IllegalStateException someState = "" // getStateValue() // will fail with IllegalStateException someState = "non-empty-state" println(getStateValue()) // non-empty-state //sampleEnd } ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` inline fun <T : Any> checkNotNull(     value: T?,     lazyMessage: () -> Any ): T ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the result of calling [lazyMessage](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?,%20kotlin.Function0((kotlin.Any)))/lazyMessage) if the [value](check-not-null#kotlin%24checkNotNull(kotlin.checkNotNull.T?,%20kotlin.Function0((kotlin.Any)))/value) is null. Otherwise returns the not null value. ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart var someState: String? = null fun getStateValue(): String { val state = checkNotNull(someState) { "State must be set beforehand" } check(state.isNotEmpty()) { "State must be non-empty" } // ... return state } // getStateValue() // will fail with IllegalStateException someState = "" // getStateValue() // will fail with IllegalStateException someState = "non-empty-state" println(getStateValue()) // non-empty-state //sampleEnd } ``` kotlin also also ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <also> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` inline fun <T> T.also(block: (T) -> Unit): T ``` Calls the specified function [block](also#kotlin%24also(kotlin.also.T,%20kotlin.Function1((kotlin.also.T,%20kotlin.Unit)))/block) with `this` value as its argument and returns `this` value. For detailed usage information see the documentation for [scope functions](../../../../../docs/scope-functions#also). kotlin runCatching runCatching =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [runCatching](run-catching) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R> runCatching(block: () -> R): Result<R> ``` Calls the specified function [block](run-catching#kotlin%24runCatching(kotlin.Function0((kotlin.runCatching.R)))/block) and returns its encapsulated result if invocation was successful, catching any [Throwable](-throwable/index#kotlin.Throwable) exception that was thrown from the [block](run-catching#kotlin%24runCatching(kotlin.Function0((kotlin.runCatching.R)))/block) function execution and encapsulating it as a failure. **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <T, R> T.runCatching(block: T.() -> R): Result<R> ``` Calls the specified function [block](run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) with `this` value as its receiver and returns its encapsulated result if invocation was successful, catching any [Throwable](-throwable/index#kotlin.Throwable) exception that was thrown from the [block](run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) function execution and encapsulating it as a failure. kotlin ushortArrayOf ushortArrayOf ============= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [ushortArrayOf](ushort-array-of) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun ushortArrayOf(     vararg elements: UShort ): UShortArray ``` kotlin mod mod === [kotlin-stdlib](../../../../../index) / [kotlin](index) / <mod> **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.mod(other: Byte): Byte ``` ``` fun Byte.mod(other: Short): Short ``` ``` fun Byte.mod(other: Int): Int ``` ``` fun Byte.mod(other: Long): Long ``` ``` fun Short.mod(other: Byte): Byte ``` ``` fun Short.mod(other: Short): Short ``` ``` fun Short.mod(other: Int): Int ``` ``` fun Short.mod(other: Long): Long ``` ``` fun Int.mod(other: Byte): Byte ``` ``` fun Int.mod(other: Short): Short ``` ``` fun Int.mod(other: Int): Int ``` ``` fun Int.mod(other: Long): Long ``` ``` fun Long.mod(other: Byte): Byte ``` ``` fun Long.mod(other: Short): Short ``` ``` fun Long.mod(other: Int): Int ``` ``` fun Long.mod(other: Long): Long ``` Calculates the remainder of flooring division of this value by the other value. The result is either zero or has the same sign as the *divisor* and has the absolute value less than the absolute value of the divisor. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Float.mod(other: Float): Float ``` ``` fun Float.mod(other: Double): Double ``` ``` fun Double.mod(other: Float): Double ``` ``` fun Double.mod(other: Double): Double ``` Calculates the remainder of flooring division of this value by the other value. The result is either zero or has the same sign as the *divisor* and has the absolute value less than the absolute value of the divisor. If the result cannot be represented exactly, it is rounded to the nearest representable number. In this case the absolute value of the result can be less than or *equal to* the absolute value of the divisor. kotlin fold fold ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <fold> **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <R, T> Result<T>.fold(     onSuccess: (value: T) -> R,     onFailure: (exception: Throwable) -> R ): R ``` Returns the result of [onSuccess](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onSuccess) for the encapsulated value if this instance represents [success](-result/is-success) or the result of [onFailure](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onFailure) function for the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if it is [failure](-result/is-failure). Note, that this function rethrows any [Throwable](-throwable/index#kotlin.Throwable) exception thrown by [onSuccess](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onSuccess) or by [onFailure](fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onFailure) function. kotlin code code ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <code> **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline val Char.code: Int ``` Returns the code of this Char. Code of a Char is the value it was constructed with, and the UTF-16 code unit corresponding to this Char. ``` import java.util.* import kotlin.test.* fun main(args: Array<String>) { //sampleStart val string = "0Azβ" println(string.map { it.code }) // [48, 65, 122, 946] //sampleEnd } ``` kotlin uintArrayOf uintArrayOf =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [uintArrayOf](uint-array-of) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes fun uintArrayOf(     vararg elements: UInt ): UIntArray ``` kotlin Annotation Annotation ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [Annotation](-annotation) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface Annotation ``` Base interface implicitly implemented by all annotation interfaces. See [Kotlin language documentation](../../../../../docs/annotations) for more information on annotations. 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> ``` Inheritors ---------- **Platform and version requirements:** JS (1.1), Native (1.1) #### [AssociatedObjectKey](../kotlin.reflect/-associated-object-key/index) Makes the annotated annotation class an associated object key. ``` annotation class AssociatedObjectKey ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [BuilderInference](-builder-inference/index) Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. ``` annotation class BuilderInference ``` **Platform and version requirements:** Native (1.3) #### [CCall](../kotlinx.cinterop.internal/-c-call/index) ``` annotation class CCall ``` **Platform and version requirements:** Native (1.3) #### [CEnumEntryAlias](../kotlinx.cinterop.internal/-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](../kotlinx.cinterop.internal/-c-enum-var-type-size/index) Stores instance size of the type T: CEnumVar. ``` annotation class CEnumVarTypeSize ``` **Platform and version requirements:** Native (1.3) #### [CName](../kotlin.native/-c-name/index) Makes top level function available from C/C++ code with the given name. ``` annotation class CName ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ContextFunctionTypeParams](-context-function-type-params/index) ``` annotation class ContextFunctionTypeParams ``` **Platform and version requirements:** Native (1.3) #### [CStruct](../kotlinx.cinterop.internal/-c-struct/index) ``` annotation class CStruct ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Deprecated](-deprecated/index) Marks the annotated declaration as deprecated. ``` annotation class Deprecated ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [DeprecatedSinceKotlin](-deprecated-since-kotlin/index) Marks the annotated declaration as deprecated. In contrast to [Deprecated](-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](-deprecated-since-kotlin/hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](-deprecated-since-kotlin/error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](-deprecated-since-kotlin/warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. ``` annotation class DeprecatedSinceKotlin ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [DslMarker](-dsl-marker/index) When applied to annotation class X specifies that X defines a DSL language ``` annotation class DslMarker ``` **Platform and version requirements:** JS (1.6) #### [EagerInitialization](../kotlin.js/-eager-initialization/index) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. ``` annotation class EagerInitialization ``` **Platform and version requirements:** Native (1.3) #### [EagerInitialization](../kotlin.native/-eager-initialization/index) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". ``` annotation class EagerInitialization ``` **Platform and version requirements:** JS (1.1), Native (1.1) #### [ExperimentalAssociatedObjects](../kotlin.reflect/-experimental-associated-objects/index) The experimental marker for associated objects API. ``` annotation class ExperimentalAssociatedObjects ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalContracts](../kotlin.contracts/-experimental-contracts/index) This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. ``` annotation class ExperimentalContracts ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [ExperimentalJsExport](../kotlin.js/-experimental-js-export/index) Marks experimental JS export annotations. ``` annotation class ExperimentalJsExport ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalMultiplatform](-experimental-multiplatform/index) The experimental multiplatform support API marker. ``` annotation class ExperimentalMultiplatform ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalObjCName](../kotlin.experimental/-experimental-obj-c-name/index) This annotation marks the experimental [ObjCName](../kotlin.native/-obj-c-name/index#kotlin.native.ObjCName) annotation. ``` annotation class ExperimentalObjCName ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalObjCRefinement](../kotlin.experimental/-experimental-obj-c-refinement/index) This annotation marks the experimental Objective-C export refinement annotations. ``` annotation class ExperimentalObjCRefinement ``` **Platform and version requirements:** JVM (1.4), JRE7 (1.4) #### [ExperimentalPathApi](../kotlin.io.path/-experimental-path-api/index) This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. ``` annotation class ExperimentalPathApi ``` **Platform and version requirements:** JVM (1.5) #### [ExperimentalReflectionOnLambdas](../kotlin.reflect.jvm/-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 ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalStdlibApi](-experimental-stdlib-api/index) This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. ``` annotation class ExperimentalStdlibApi ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [ExperimentalSubclassOptIn](-experimental-subclass-opt-in/index) This annotation marks the experimental preview of the language feature [SubclassOptInRequired](-subclass-opt-in-required/index). ``` annotation class ExperimentalSubclassOptIn ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalTime](../kotlin.time/-experimental-time/index) This annotation marks the experimental preview of the standard library API for measuring time and working with durations. ``` annotation class ExperimentalTime ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalTypeInference](../kotlin.experimental/-experimental-type-inference/index) The experimental marker for type inference augmenting annotations. ``` annotation class ExperimentalTypeInference ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalUnsignedTypes](-experimental-unsigned-types/index) Marks the API that is dependent on the experimental unsigned types, including those types themselves. ``` annotation class ExperimentalUnsignedTypes ``` **Platform and version requirements:** Native (1.3) #### [ExportObjCClass](../kotlinx.cinterop/-export-obj-c-class/index) Makes Kotlin subclass of Objective-C class visible for runtime lookup after Kotlin `main` function gets invoked. ``` annotation class ExportObjCClass ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExtensionFunctionType](-extension-function-type/index) Signifies that the annotated functional type represents an extension function. ``` annotation class ExtensionFunctionType ``` **Platform and version requirements:** Native (1.3) #### [ExternalObjCClass](../kotlinx.cinterop/-external-obj-c-class/index) ``` annotation class ExternalObjCClass ``` **Platform and version requirements:** #### [FreezingIsDeprecated](../kotlin.native/-freezing-is-deprecated) Freezing API is deprecated since 1.7.20. ``` annotation class FreezingIsDeprecated ``` **Platform and version requirements:** Native (1.0) #### [HiddenFromObjC](../kotlin.native/-hidden-from-obj-c/index) Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. ``` annotation class HiddenFromObjC ``` **Platform and version requirements:** Native (1.0) #### [HidesFromObjC](../kotlin.native/-hides-from-obj-c/index) Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. ``` annotation class HidesFromObjC ``` **Platform and version requirements:** Native (1.3) #### [InteropStubs](../kotlinx.cinterop/-interop-stubs/index) ``` annotation class InteropStubs ``` **Platform and version requirements:** Native (1.7) #### [IntrinsicConstEvaluation](../kotlin.internal/-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 ``` **Platform and version requirements:** JS (1.3) #### [JsExport](../kotlin.js/-js-export/index) Exports top-level declaration on JS platform. ``` annotation class JsExport ``` **Platform and version requirements:** JS (1.1) #### [JsModule](../kotlin.js/-js-module/index) Denotes an `external` declaration that must be imported from native JavaScript library. ``` annotation class JsModule ``` **Platform and version requirements:** JS (1.0) #### [JsName](../kotlin.js/-js-name/index) Gives a declaration (a function, a property or a class) specific name in JavaScript. ``` annotation class JsName ``` **Platform and version requirements:** JS (1.1) #### [JsNonModule](../kotlin.js/-js-non-module/index) Denotes an `external` declaration that can be used without module system. ``` annotation class JsNonModule ``` **Platform and version requirements:** JS (1.1) #### [JsQualifier](../kotlin.js/-js-qualifier/index) Adds prefix to `external` declarations in a source file. ``` annotation class JsQualifier ``` **Platform and version requirements:** JVM (1.2) #### [JvmDefault](../kotlin.jvm/-jvm-default/index) Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. ``` annotation class JvmDefault ``` **Platform and version requirements:** JVM (1.6) #### [JvmDefaultWithCompatibility](../kotlin.jvm/-jvm-default-with-compatibility/index) Forces the compiler to generate compatibility accessors for the annotated interface in the `DefaultImpls` class. Please note that if an interface is annotated with this annotation for binary compatibility, public derived Kotlin interfaces should also be annotated with it, because their `DefaultImpls` methods will be used to access implementations from the `DefaultImpls` class of the original interface. ``` annotation class JvmDefaultWithCompatibility ``` **Platform and version requirements:** JVM (1.4) #### [JvmDefaultWithoutCompatibility](../kotlin.jvm/-jvm-default-without-compatibility/index) Prevents the compiler from generating compatibility accessors for the annotated class or interface, and suppresses any related compatibility warnings. In other words, this annotation makes the compiler generate the annotated class or interface in the `-Xjvm-default=all` mode, where only JVM default methods are generated, without `DefaultImpls`. ``` annotation class JvmDefaultWithoutCompatibility ``` **Platform and version requirements:** JVM (1.0) #### [JvmField](../kotlin.jvm/-jvm-field/index) Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field. ``` annotation class JvmField ``` **Platform and version requirements:** JVM (1.5) #### [JvmInline](../kotlin.jvm/-jvm-inline/index) Specifies that given value class is inline class. ``` annotation class JvmInline ``` **Platform and version requirements:** JVM (1.0) #### [JvmMultifileClass](../kotlin.jvm/-jvm-multifile-class/index) Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts. Name of the corresponding multifile class is provided by the [JvmName](../kotlin.jvm/-jvm-name/index#kotlin.jvm.JvmName) annotation. ``` annotation class JvmMultifileClass ``` **Platform and version requirements:** JVM (1.0) #### [JvmName](../kotlin.jvm/-jvm-name/index) Specifies the name for the Java class or method which is generated from this element. ``` annotation class JvmName ``` **Platform and version requirements:** JVM (1.0) #### [JvmOverloads](../kotlin.jvm/-jvm-overloads/index) Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values. ``` annotation class JvmOverloads ``` **Platform and version requirements:** JVM (1.5) #### [JvmRecord](../kotlin.jvm/-jvm-record/index) Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods ``` annotation class JvmRecord ``` **Platform and version requirements:** JVM (1.8) #### [JvmSerializableLambda](../kotlin.jvm/-jvm-serializable-lambda/index) Makes the annotated lambda function implement `java.io.Serializable`, generates a pretty `toString` implementation and adds reflection metadata. ``` annotation class JvmSerializableLambda ``` **Platform and version requirements:** JVM (1.0) #### [JvmStatic](../kotlin.jvm/-jvm-static/index) Specifies that an additional static method needs to be generated from this element if it's a function. If this element is a property, additional static getter/setter methods should be generated. ``` annotation class JvmStatic ``` **Platform and version requirements:** JVM (1.0) #### [JvmSuppressWildcards](../kotlin.jvm/-jvm-suppress-wildcards/index) Instructs compiler to generate or omit wildcards for type arguments corresponding to parameters with declaration-site variance, for example such as `Collection<out T>` has. ``` annotation class JvmSuppressWildcards ``` **Platform and version requirements:** JVM (1.0) #### [JvmSynthetic](../kotlin.jvm/-jvm-synthetic/index) Sets `ACC_SYNTHETIC` flag on the annotated target in the Java bytecode. ``` annotation class JvmSynthetic ``` **Platform and version requirements:** JVM (1.0) #### [JvmWildcard](../kotlin.jvm/-jvm-wildcard/index) Instructs compiler to generate wildcard for annotated type arguments corresponding to parameters with declaration-site variance. ``` annotation class JvmWildcard ``` **Platform and version requirements:** JVM (1.3) #### [Metadata](-metadata/index) This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. ``` annotation class Metadata ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MustBeDocumented](../kotlin.annotation/-must-be-documented/index) This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. ``` annotation class MustBeDocumented ``` **Platform and version requirements:** JS (1.1) #### [nativeGetter](../kotlin.js/native-getter/index) ``` annotation class nativeGetter ``` **Platform and version requirements:** JS (1.1) #### [nativeInvoke](../kotlin.js/native-invoke/index) ``` annotation class nativeInvoke ``` **Platform and version requirements:** JS (1.1) #### [nativeSetter](../kotlin.js/native-setter/index) ``` annotation class nativeSetter ``` **Platform and version requirements:** Native (1.3) #### [ObjCAction](../kotlinx.cinterop/-obj-c-action/index) Makes Kotlin method in Objective-C class accessible through Objective-C dispatch to be used as action sent by control in UIKit or AppKit. ``` annotation class ObjCAction ``` **Platform and version requirements:** Native (1.3) #### [ObjCConstructor](../kotlinx.cinterop/-obj-c-constructor/index) ``` annotation class ObjCConstructor ``` **Platform and version requirements:** Native (1.3) #### [ObjCFactory](../kotlinx.cinterop/-obj-c-factory/index) ``` annotation class ObjCFactory ``` **Platform and version requirements:** Native (1.3) #### [ObjCMethod](../kotlinx.cinterop/-obj-c-method/index) ``` annotation class ObjCMethod ``` **Platform and version requirements:** Native (1.0) #### [ObjCName](../kotlin.native/-obj-c-name/index) Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. ``` annotation class ObjCName ``` **Platform and version requirements:** Native (1.3) #### [ObjCOutlet](../kotlinx.cinterop/-obj-c-outlet/index) Makes Kotlin property in Objective-C class settable through Objective-C dispatch to be used as IB outlet. ``` annotation class ObjCOutlet ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [OptIn](-opt-in/index) Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](-opt-in/index), its usages are **not** required to opt in to that API. ``` annotation class OptIn ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [OptionalExpectation](-optional-expectation/index) Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. ``` annotation class OptionalExpectation ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [OverloadResolutionByLambdaReturnType](-overload-resolution-by-lambda-return-type/index) Enables overload selection based on the type of the value returned from lambda argument. ``` annotation class OverloadResolutionByLambdaReturnType ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ParameterName](-parameter-name/index) Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). ``` annotation class ParameterName ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [PublishedApi](-published-api/index) When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. ``` annotation class PublishedApi ``` **Platform and version requirements:** JVM (1.0) #### [PurelyImplements](../kotlin.jvm/-purely-implements/index) Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. "Pure" means here that each type parameter of class becomes non-platform type argument of that interface. ``` annotation class PurelyImplements ``` **Platform and version requirements:** Native (1.0) #### [RefinesInSwift](../kotlin.native/-refines-in-swift/index) Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. ``` annotation class RefinesInSwift ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Repeatable](../kotlin.annotation/-repeatable/index) This meta-annotation determines that an annotation is applicable twice or more on a single code element ``` annotation class Repeatable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ReplaceWith](-replace-with/index) Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. ``` annotation class ReplaceWith ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RequiresOptIn](-requires-opt-in/index) Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. ``` annotation class RequiresOptIn ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RestrictsSuspension](../kotlin.coroutines/-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 ``` **Platform and version requirements:** Native (1.3) #### [Retain](../kotlin.native/-retain/index) Preserve the function entry point during global optimizations. ``` annotation class Retain ``` **Platform and version requirements:** Native (1.3) #### [RetainForTarget](../kotlin.native/-retain-for-target/index) Preserve the function entry point during global optimizations, only for the given target. ``` annotation class RetainForTarget ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Retention](../kotlin.annotation/-retention/index) This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. ``` annotation class Retention ``` **Platform and version requirements:** Native (1.0) #### [SharedImmutable](../kotlin.native.concurrent/-shared-immutable/index) Note: this annotation has effect only in Kotlin/Native with legacy memory manager. ``` annotation class SharedImmutable ``` **Platform and version requirements:** Native (1.0) #### [ShouldRefineInSwift](../kotlin.native/-should-refine-in-swift/index) Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. ``` annotation class ShouldRefineInSwift ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SinceKotlin](-since-kotlin/index) Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. ``` annotation class SinceKotlin ``` **Platform and version requirements:** JVM (1.0) #### [Strictfp](../kotlin.jvm/-strictfp/index) Marks the JVM method generated from the annotated function as `strictfp`, meaning that the precision of floating point operations performed inside the method needs to be restricted in order to achieve better portability. ``` annotation class Strictfp ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [SubclassOptInRequired](-subclass-opt-in-required/index) Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. ``` annotation class SubclassOptInRequired ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Suppress](-suppress/index) Suppresses the given compilation warnings in the annotated element. ``` annotation class Suppress ``` **Platform and version requirements:** Native (1.3) #### [SymbolName](../kotlin.native/-symbol-name/index) This is a dangerous deprecated and internal annotation. Please avoid using it. ``` annotation class SymbolName ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [Synchronized](../kotlin.jvm/-synchronized/index) Marks the JVM method generated from the annotated function as `synchronized`, meaning that the method will be protected from concurrent execution by multiple threads by the monitor of the instance (or, for static methods, the class) on which the method is defined. ``` annotation class Synchronized ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Target](../kotlin.annotation/-target/index) This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. ``` annotation class Target ``` **Platform and version requirements:** Native (1.0) #### [ThreadLocal](../kotlin.native.concurrent/-thread-local/index) Marks a top level property with a backing field or an object as thread local. The object remains mutable and it is possible to change its state, but every thread will have a distinct copy of this object, so changes in one thread are not reflected in another. ``` annotation class ThreadLocal ``` #### [Throws](-throws/index) This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. **Platform and version requirements:** Native (1.4) ``` annotation class Throws ``` **Platform and version requirements:** JVM (1.4) ``` typealias Throws = Throws ``` **Platform and version requirements:** JVM (1.0) #### [Throws](../kotlin.jvm/-throws/index) This annotation indicates what exceptions should be declared by a function when compiled to a JVM method. ``` annotation class Throws ``` **Platform and version requirements:** JVM (1.0) #### [Transient](../kotlin.jvm/-transient/index) Marks the JVM backing field of the annotated property as `transient`, meaning that it is not part of the default serialized form of the object. ``` annotation class Transient ``` **Platform and version requirements:** Native (1.3) #### [UnsafeNumber](../kotlinx.cinterop/-unsafe-number/index) Marker for declarations that depend on numeric types of different bit width on at least two platforms. ``` annotation class UnsafeNumber ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [UnsafeVariance](-unsafe-variance/index) Suppresses errors about variance conflict ``` annotation class UnsafeVariance ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [Volatile](../kotlin.jvm/-volatile/index) Marks the JVM backing field of the annotated property as `volatile`, meaning that writes to this field are immediately made visible to other threads. ``` annotation class Volatile ```
programming_docs
kotlin rotateLeft rotateLeft ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [rotateLeft](rotate-left) **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Int.rotateLeft(bitCount: Int): Int ``` Rotates the binary representation of this [Int](-int/index#kotlin.Int) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Int,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [Int.SIZE\_BITS](-int/-s-i-z-e_-b-i-t-s#kotlin.Int.Companion%24SIZE_BITS) (32) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 32)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Long.rotateLeft(bitCount: Int): Long ``` Rotates the binary representation of this [Long](-long/index#kotlin.Long) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Long,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [Long.SIZE\_BITS](-long/-s-i-z-e_-b-i-t-s#kotlin.Long.Companion%24SIZE_BITS) (64) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 64)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Byte.rotateLeft(bitCount: Int): Byte ``` Rotates the binary representation of this [Byte](-byte/index#kotlin.Byte) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Byte,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [Byte.SIZE\_BITS](-byte/-s-i-z-e_-b-i-t-s#kotlin.Byte.Companion%24SIZE_BITS) (8) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 8)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun Short.rotateLeft(bitCount: Int): Short ``` Rotates the binary representation of this [Short](-short/index#kotlin.Short) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.Short,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [Short.SIZE\_BITS](-short/-s-i-z-e_-b-i-t-s#kotlin.Short.Companion%24SIZE_BITS) (16) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 16)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UInt.rotateLeft(bitCount: Int): UInt ``` Rotates the binary representation of this [UInt](-u-int/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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [UInt.SIZE\_BITS](-u-int/-s-i-z-e_-b-i-t-s) (32) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 32)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun ULong.rotateLeft(bitCount: Int): ULong ``` Rotates the binary representation of this [ULong](-u-long/index) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.ULong,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [ULong.SIZE\_BITS](-u-long/-s-i-z-e_-b-i-t-s) (64) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 64)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UByte.rotateLeft(bitCount: Int): UByte ``` Rotates the binary representation of this [UByte](-u-byte/index) number left by the specified [bitCount](rotate-left#kotlin%24rotateLeft(kotlin.UByte,%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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [UByte.SIZE\_BITS](-u-byte/-s-i-z-e_-b-i-t-s) (8) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 8)` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) ``` fun UShort.rotateLeft(bitCount: Int): UShort ``` Rotates the binary representation of this [UShort](-u-short/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. Rotating the number left by a negative bit count is the same as rotating it right by the negated bit count: `number.rotateLeft(-n) == number.rotateRight(n)` Rotating by a multiple of [UShort.SIZE\_BITS](-u-short/-s-i-z-e_-b-i-t-s) (16) returns the same number, or more generally `number.rotateLeft(n) == number.rotateLeft(n % 16)` kotlin onFailure onFailure ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [onFailure](on-failure) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline fun <T> Result<T>.onFailure(     action: (exception: Throwable) -> Unit ): Result<T> ``` Performs the given [action](on-failure#kotlin%24onFailure(kotlin.Result((kotlin.onFailure.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.Unit)))/action) on the encapsulated [Throwable](-throwable/index#kotlin.Throwable) exception if this instance represents [failure](-result/is-failure). Returns the original `Result` unchanged. kotlin toUByte toUByte ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toUByte](to-u-byte) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.toUByte(): UByte ``` Converts this [Byte](-byte/index#kotlin.Byte) value to [UByte](-u-byte/index). If this value is positive, the resulting `UByte` value represents the same numerical value as this `Byte`. The resulting `UByte` value has the same binary representation as this `Byte` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Short.toUByte(): UByte ``` Converts this [Short](-short/index#kotlin.Short) value to [UByte](-u-byte/index). If this value is positive and 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 `Short`. The resulting `UByte` value is represented by the least significant 8 bits of this `Short` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.toUByte(): UByte ``` Converts this [Int](-int/index#kotlin.Int) value to [UByte](-u-byte/index). If this value is positive and 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 `Int`. The resulting `UByte` value is represented by the least significant 8 bits of this `Int` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Long.toUByte(): UByte ``` Converts this [Long](-long/index#kotlin.Long) value to [UByte](-u-byte/index). If this value is positive and 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 `Long`. The resulting `UByte` value is represented by the least significant 8 bits of this `Long` value. kotlin enumValues enumValues ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [enumValues](enum-values) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.3) ``` fun <reified T : Enum<T>> enumValues(): Array<T> ``` Returns an array containing enum T entries. kotlin suppressedExceptions suppressedExceptions ==================== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [suppressedExceptions](suppressed-exceptions) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` val Throwable.suppressedExceptions: List<Throwable> ``` ##### For Common, JVM Returns a list of all exceptions that were suppressed in order to deliver this exception. The list can be empty: * if no exceptions were suppressed; * if the platform doesn't support suppressed exceptions; * if this [Throwable](-throwable/index#kotlin.Throwable) instance has disabled the suppression. ##### For JS, Native Returns a list of all exceptions that were suppressed in order to deliver this exception. kotlin isInfinite isInfinite ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [isInfinite](is-infinite) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Double.isInfinite(): Boolean ``` ``` fun Float.isInfinite(): Boolean ``` Returns `true` if this value is infinitely large in magnitude. kotlin floorDiv floorDiv ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [floorDiv](floor-div) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.floorDiv(other: Byte): Int ``` ``` fun Byte.floorDiv(other: Short): Int ``` ``` fun Byte.floorDiv(other: Int): Int ``` ``` fun Byte.floorDiv(other: Long): Long ``` ``` fun Short.floorDiv(other: Byte): Int ``` ``` fun Short.floorDiv(other: Short): Int ``` ``` fun Short.floorDiv(other: Int): Int ``` ``` fun Short.floorDiv(other: Long): Long ``` ``` fun Int.floorDiv(other: Byte): Int ``` ``` fun Int.floorDiv(other: Short): Int ``` ``` fun Int.floorDiv(other: Int): Int ``` ``` fun Int.floorDiv(other: Long): Long ``` ``` fun Long.floorDiv(other: Byte): Long ``` ``` fun Long.floorDiv(other: Short): Long ``` ``` fun Long.floorDiv(other: Int): Long ``` ``` fun Long.floorDiv(other: Long): Long ``` Divides this value by the other value, flooring the result to an integer that is closer to negative infinity. kotlin toRawBits toRawBits ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toRawBits](to-raw-bits) **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Double.toRawBits(): Long ``` Returns a bit representation of the specified floating-point value as [Long](-long/index#kotlin.Long) according to the IEEE 754 floating-point "double format" bit layout, preserving `NaN` values exact layout. **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) ``` fun Float.toRawBits(): Int ``` ##### For Common, JVM, Native Returns a bit representation of the specified floating-point value as [Int](-int/index#kotlin.Int) according to the IEEE 754 floating-point "single format" bit layout, preserving `NaN` values exact layout. ##### For JS Returns a bit representation of the specified floating-point value as Int according to the IEEE 754 floating-point "single format" bit layout, preserving `NaN` values exact layout. Note that in Kotlin/JS Float range is wider than "single format" bit layout can represent, so some Float values may overflow, underflow or loose their accuracy after conversion to bits and back. kotlin Nothing Nothing ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [Nothing](-nothing) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Nothing ``` Nothing has no instances. You can use Nothing to represent "a value that never exists": for example, if a function has the return type of Nothing, it means that it never returns (always throws an exception). kotlin toULong toULong ======= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toULong](to-u-long) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.toULong(): ULong ``` Converts this [Byte](-byte/index#kotlin.Byte) value to [ULong](-u-long/index). If this value is positive, the resulting `ULong` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `ULong` 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. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Short.toULong(): ULong ``` Converts this [Short](-short/index#kotlin.Short) value to [ULong](-u-long/index). If this value is positive, the resulting `ULong` value represents the same numerical value as this `Short`. The least significant 16 bits of the resulting `ULong` value are the same as the bits of this `Short` value, whereas the most significant 48 bits are filled with the sign bit of this value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.toULong(): ULong ``` Converts this [Int](-int/index#kotlin.Int) value to [ULong](-u-long/index). If this value is positive, the resulting `ULong` value represents the same numerical value as this `Int`. The least significant 32 bits of the resulting `ULong` value are the same as the bits of this `Int` value, whereas the most significant 32 bits are filled with the sign bit of this value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Long.toULong(): ULong ``` Converts this [Long](-long/index#kotlin.Long) value to [ULong](-u-long/index). If this value is positive, the resulting `ULong` value represents the same numerical value as this `Long`. The resulting `ULong` value has the same binary representation as this `Long` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Float.toULong(): ULong ``` Converts this [Float](-float/index#kotlin.Float) value to [ULong](-u-long/index). The fractional part, if any, is rounded down towards zero. Returns zero if this `Float` value is negative or `NaN`, [ULong.MAX\_VALUE](-u-long/-m-a-x_-v-a-l-u-e) if it's bigger than `ULong.MAX_VALUE`. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Double.toULong(): ULong ``` Converts this [Double](-double/index#kotlin.Double) value to [ULong](-u-long/index). The fractional part, if any, is rounded down towards zero. Returns zero if this `Double` value is negative or `NaN`, [ULong.MAX\_VALUE](-u-long/-m-a-x_-v-a-l-u-e) if it's bigger than `ULong.MAX_VALUE`. kotlin ULongArray ULongArray ========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [ULongArray](-u-long-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline fun ULongArray(     size: Int,     init: (Int) -> ULong ): ULongArray ``` Creates a new array of the specified [size](-u-long-array#kotlin%24ULongArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/size), where each element is calculated by calling the specified [init](-u-long-array#kotlin%24ULongArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/init) function. The function [init](-u-long-array#kotlin%24ULongArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.ULong)))/init) is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. kotlin longArrayOf longArrayOf =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [longArrayOf](long-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun longArrayOf(vararg elements: Long): LongArray ``` Returns an array containing the specified [Long](-long/index#kotlin.Long) numbers. kotlin plus plus ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun String?.plus(other: Any?): String ``` Concatenates this string with the string representation of the given [other](plus#kotlin%24plus(kotlin.String?,%20kotlin.Any?)/other) object. If either the receiver or the [other](plus#kotlin%24plus(kotlin.String?,%20kotlin.Any?)/other) object are null, they are represented as the string "null". kotlin error error ===== [kotlin-stdlib](../../../../../index) / [kotlin](index) / <error> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun error(message: Any): Nothing ``` Throws an [IllegalStateException](-illegal-state-exception/index#kotlin.IllegalStateException) with the given [message](error#kotlin%24error(kotlin.Any)/message). ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val name: String? = null // val nonNullName = name ?: error("Name is missing") // will fail with IllegalStateException //sampleEnd } ``` kotlin toBigDecimal toBigDecimal ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toBigDecimal](to-big-decimal) **Platform and version requirements:** JVM (1.2) ``` fun Int.toBigDecimal(): BigDecimal ``` Returns the value of this [Int](-int/index#kotlin.Int) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). **Platform and version requirements:** JVM (1.2) ``` fun Int.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Int](-int/index#kotlin.Int) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). Parameters ---------- `mathContext` - specifies the precision and the rounding mode. **Platform and version requirements:** JVM (1.2) ``` fun Long.toBigDecimal(): BigDecimal ``` Returns the value of this [Long](-long/index#kotlin.Long) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). **Platform and version requirements:** JVM (1.2) ``` fun Long.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Long](-long/index#kotlin.Long) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). Parameters ---------- `mathContext` - specifies the precision and the rounding mode. **Platform and version requirements:** JVM (1.2) ``` fun Float.toBigDecimal(): BigDecimal ``` Returns the value of this [Float](-float/index#kotlin.Float) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). The number is converted to a string and then the string is converted to a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). **Platform and version requirements:** JVM (1.2) ``` fun Float.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Float](-float/index#kotlin.Float) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). The number is converted to a string and then the string is converted to a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). Parameters ---------- `mathContext` - specifies the precision and the rounding mode. **Platform and version requirements:** JVM (1.2) ``` fun Double.toBigDecimal(): BigDecimal ``` Returns the value of this [Double](-double/index#kotlin.Double) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). The number is converted to a string and then the string is converted to a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). **Platform and version requirements:** JVM (1.2) ``` fun Double.toBigDecimal(mathContext: MathContext): BigDecimal ``` Returns the value of this [Double](-double/index#kotlin.Double) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). The number is converted to a string and then the string is converted to a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). Parameters ---------- `mathContext` - specifies the precision and the rounding mode.
programming_docs
kotlin shortArrayOf shortArrayOf ============ [kotlin-stdlib](../../../../../index) / [kotlin](index) / [shortArrayOf](short-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun shortArrayOf(vararg elements: Short): ShortArray ``` Returns an array containing the specified [Short](-short/index#kotlin.Short) numbers. kotlin charArrayOf charArrayOf =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [charArrayOf](char-array-of) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun charArrayOf(vararg elements: Char): CharArray ``` Returns an array containing the specified characters. kotlin isNaN isNaN ===== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [isNaN](is-na-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun Double.isNaN(): Boolean ``` ``` fun Float.isNaN(): Boolean ``` Returns `true` if the specified number is a Not-a-Number (NaN) value, `false` otherwise. kotlin UIntArray UIntArray ========= [kotlin-stdlib](../../../../../index) / [kotlin](index) / [UIntArray](-u-int-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline fun UIntArray(     size: Int,     init: (Int) -> UInt ): UIntArray ``` Creates a new array of the specified [size](-u-int-array#kotlin%24UIntArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/size), where each element is calculated by calling the specified [init](-u-int-array#kotlin%24UIntArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/init) function. The function [init](-u-int-array#kotlin%24UIntArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/init) is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. kotlin TODO TODO ==== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [TODO](-t-o-d-o) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun TODO(): Nothing ``` Always throws [NotImplementedError](-not-implemented-error/index) stating that operation is not implemented. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun TODO(reason: String): Nothing ``` Always throws [NotImplementedError](-not-implemented-error/index) stating that operation is not implemented. Parameters ---------- `reason` - a string explaining why the implementation is missing. kotlin toUShort toUShort ======== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [toUShort](to-u-short) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Byte.toUShort(): UShort ``` Converts this [Byte](-byte/index#kotlin.Byte) value to [UShort](-u-short/index). If this value is positive, the resulting `UShort` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `UShort` 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. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Short.toUShort(): UShort ``` Converts this [Short](-short/index#kotlin.Short) value to [UShort](-u-short/index). If this value is positive, the resulting `UShort` value represents the same numerical value as this `Short`. The resulting `UShort` value has the same binary representation as this `Short` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Int.toUShort(): UShort ``` Converts this [Int](-int/index#kotlin.Int) value to [UShort](-u-short/index). If this value is positive and 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 `Int`. The resulting `UShort` value is represented by the least significant 16 bits of this `Int` value. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun Long.toUShort(): UShort ``` Converts this [Long](-long/index#kotlin.Long) value to [UShort](-u-short/index). If this value is positive and 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 `Long`. The resulting `UShort` value is represented by the least significant 16 bits of this `Long` value. kotlin UShortArray UShortArray =========== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [UShortArray](-u-short-array) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline fun UShortArray(     size: Int,     init: (Int) -> UShort ): UShortArray ``` Creates a new array of the specified [size](-u-short-array#kotlin%24UShortArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/size), where each element is calculated by calling the specified [init](-u-short-array#kotlin%24UShortArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/init) function. The function [init](-u-short-array#kotlin%24UShortArray(kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/init) is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. kotlin countTrailingZeroBits countTrailingZeroBits ===================== [kotlin-stdlib](../../../../../index) / [kotlin](index) / [countTrailingZeroBits](count-trailing-zero-bits) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Int.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Int](-int/index#kotlin.Int) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Long.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Long](-long/index#kotlin.Long) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Byte.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Byte](-byte/index#kotlin.Byte) number. **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` fun Short.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [Short](-short/index#kotlin.Short) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UInt.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UInt](-u-int/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun ULong.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [ULong](-u-long/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UByte.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UByte](-u-byte/index) number. **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` fun UShort.countTrailingZeroBits(): Int ``` Counts the number of consecutive least significant bits that are zero in the binary representation of this [UShort](-u-short/index) number. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin Array Array ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Array<T> ``` ##### For Common, JVM, JS Represents an array (specifically, a Java array when targeting the JVM platform). Array instances can be created using the [arrayOf](../array-of#kotlin%24arrayOf(kotlin.Array((kotlin.arrayOf.T)))), [arrayOfNulls](../array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)) and [emptyArray](../empty-array#kotlin%24emptyArray()) standard library functions. See [Kotlin language documentation](../../../../../../docs/basic-types#arrays) for more information on arrays. ##### For Native Represents an array. Array instances can be created using the constructor, [arrayOf](../array-of#kotlin%24arrayOf(kotlin.Array((kotlin.arrayOf.T)))), [arrayOfNulls](../array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)) and [emptyArray](../empty-array#kotlin%24emptyArray()) standard library functions. See [Kotlin language documentation](../../../../../../docs/basic-types#arrays) for more information on arrays. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array with the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> T) ``` 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) #### <get> Returns the array element at the specified [index](get#kotlin.Array%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <iterator> Creates an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) for iterating over the elements of the array. ``` operator fun iterator(): Iterator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the array element at the specified [index](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/index) to the specified [value](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: T) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val <T> Array<out T>.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val <T> Array<out 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.Array((kotlin.collections.all.T)),%20kotlin.Function1((kotlin.collections.all.T,%20kotlin.Boolean)))/predicate). ``` fun <T> Array<out 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 <T> Array<out T>.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun <T> Array<out T>.asIterable(): Iterable<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 array returning its elements when being iterated. ``` fun <T> Array<out 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.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> Array<out 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 array indexed by the key returned from [keySelector](../../kotlin.collections/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> Array<out 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.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](../../kotlin.collections/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> Array<out 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.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](../../kotlin.collections/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>> Array<out T>.associateByTo(     destination: M,     keySelector: (T) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/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](../../kotlin.collections/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](../../kotlin.collections/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>> Array<out 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.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](../../kotlin.collections/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>> Array<out T>.associateTo(     destination: M,     transform: (T) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.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> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/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](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0) #### [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.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](../../kotlin.collections/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 ``` Searches the array or the range of the array for the provided [element](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun <T> Array<out 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 array. ``` operator fun <T> Array<out 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 array. ``` operator fun <T> Array<out 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 array. ``` operator fun <T> Array<out 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 array. ``` operator fun <T> Array<out 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.Array((kotlin.collections.contains.T)),%20kotlin.collections.contains.T)/element) is found in the array. ``` operator fun <T> Array<out T>.contains(element: T): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun <T> Array<out T>.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/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 ``` **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 array. ``` fun <T> Array<out 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 array having distinct keys returned by the given [selector](../../kotlin.collections/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> Array<out 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.Array((kotlin.collections.drop.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out 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.Array((kotlin.collections.dropLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out 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.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> ``` **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.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> ``` **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.Array((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.Array((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.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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.Array((kotlin.collections.elementAtOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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? ``` **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.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> ``` **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.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> ``` **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.Array((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.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 ``` #### [filterIsInstance](../../kotlin.collections/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> ``` **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> ``` #### [filterIsInstanceTo](../../kotlin.collections/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](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0) Appends all elements that are instances of specified class to the given [destination](../../kotlin.collections/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 ``` **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.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> ``` **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> Array<out 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.Array((kotlin.collections.filterNotNullTo.T?)),%20kotlin.collections.filterNotNullTo.C)/destination). ``` fun <C : MutableCollection<in T>, T : Any> Array<out 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.Array((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.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 ``` **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.Array((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.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 ``` **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.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? ``` **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.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? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun <T> Array<out T>.first(): T ``` Returns the first element matching the given [predicate](../../kotlin.collections/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 ``` **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.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](../-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 ``` **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.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? ``` **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 <T> Array<out T>.firstOrNull(): T? ``` Returns the first element matching the given [predicate](../../kotlin.collections/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? ``` **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.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> any_array<T>.flatMap(     transform: (T) -> Iterable<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.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> any_array<T>.flatMapIndexed(     transform: (index: Int, T) -> Iterable<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.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](../../kotlin.collections/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>> any_array<T>.flatMapIndexedTo(     destination: C,     transform: (index: Int, T) -> Iterable<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.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](../../kotlin.collections/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>> any_array<T>.flatMapTo(     destination: C,     transform: (T) -> Iterable<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 arrays in the given array. ``` fun <T> Array<out Array<out 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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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 ``` **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.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) ``` **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.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) ``` **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.Array((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.Array((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.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 ``` **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.Array((kotlin.collections.getOrNull.T)),%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/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? ``` **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.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>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/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](../../kotlin.collections/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>> ``` **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.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](../../kotlin.collections/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 ``` Groups values returned by the [valueTransform](../../kotlin.collections/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](../../kotlin.collections/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](../../kotlin.collections/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 ``` **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 an array to be used later with one of group-and-fold operations using the specified [keySelector](../../kotlin.collections/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> ``` **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.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 ``` **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.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 ``` **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.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 ``` **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 array and the specified collection. ``` infix fun <T> Array<out T>.intersect(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0) #### [isArrayOf](../../kotlin.jvm/is-array-of) Checks if array can contain element of type [T](../../kotlin.jvm/is-array-of#T). ``` fun <T : Any> Array<*>.isArrayOf(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun <T> Array<out T>.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun <T> Array<out 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 array is either null or empty. ``` fun Array<*>?.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.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](../../kotlin.collections/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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [last](../../kotlin.collections/last) Returns the last element. ``` fun <T> Array<out T>.last(): T ``` Returns the last element matching the given [predicate](../../kotlin.collections/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 ``` **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.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 ``` **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 <T> Array<out T>.lastOrNull(): T? ``` Returns the last element matching the given [predicate](../../kotlin.collections/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? ``` **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.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> ``` **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.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> ``` **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.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> ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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 ``` **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.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> ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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 ``` **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>> Array<out 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.Array((kotlin.collections.maxOf.T)),%20kotlin.Function1((kotlin.collections.maxOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> any_array<T>.maxOf(selector: (T) -> Double): Double ``` **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.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> any_array<T>.maxOfOrNull(     selector: (T) -> Double ): Double? ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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? ``` **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 <T : Comparable<T>> any_array<T>.maxOrNull(): T? ``` #### [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.Array((kotlin.collections.maxWith.T)),%20kotlin.Comparator((kotlin.collections.maxWith.T)))/comparator). ``` fun <T> Array<out T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out 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.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? ``` **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>> Array<out 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.Array((kotlin.collections.minOf.T)),%20kotlin.Function1((kotlin.collections.minOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> any_array<T>.minOf(selector: (T) -> Double): Double ``` **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.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> any_array<T>.minOfOrNull(     selector: (T) -> Double ): Double? ``` **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.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](../../kotlin.collections/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 ``` **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.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](../../kotlin.collections/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? ``` **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 <T : Comparable<T>> any_array<T>.minOrNull(): 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.Array((kotlin.collections.minWith.T)),%20kotlin.Comparator((kotlin.collections.minWith.T)))/comparator). ``` fun <T> Array<out T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.0) ``` fun <T> Array<out 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.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? ``` **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 <T> Array<out T>.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/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> ``` **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.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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/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](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.Array((kotlin.collections.partition.T)),%20kotlin.Function1((kotlin.collections.partition.T,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun <T> Array<out T>.partition(     predicate: (T) -> Boolean ): Pair<List<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 <T> Array<out T>.random(): T ``` Returns a random element from this array using the specified source of randomness. ``` fun <T> Array<out 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 array, or `null` if this array is empty. ``` fun <T> Array<out T>.randomOrNull(): T? ``` 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? ``` **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.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 ``` **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.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 ``` **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.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? ``` **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.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? ``` **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.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 ``` **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.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 ``` **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.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? ``` **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.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? ``` **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> Array<T?>.requireNoNulls(): Array<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun <T> Array<T>.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun <T> Array<T>.reverse(fromIndex: Int, toIndex: Int) ``` **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> Array<out T>.reversed(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun <T> Array<T>.reversedArray(): Array<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.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](../../kotlin.collections/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> ``` **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.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](../../kotlin.collections/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> ``` **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.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> ``` **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.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> ``` **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.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](../../kotlin.collections/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> ``` **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.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](../../kotlin.collections/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> ``` **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 <T> Array<T>.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/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) ``` **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 <T> Array<out T>.single(): T ``` Returns the single element matching the given [predicate](../../kotlin.collections/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 ``` **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 <T> Array<out T>.singleOrNull(): T? ``` Returns the single element matching the given [predicate](../../kotlin.collections/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? ``` **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.Array((kotlin.collections.slice.T)),%20kotlin.ranges.IntRange)/indices) range. ``` fun <T> Array<out T>.slice(indices: IntRange): List<T> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/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> ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/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> ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.Array((kotlin.collections.sort.T)),%20kotlin.Function2((kotlin.collections.sort.T,%20,%20kotlin.Int)))/comparison) function. ``` fun <T> Array<out T>.sort(comparison: (a: T, b: T) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortBy](../../kotlin.collections/sort-by) Sorts elements in the array in-place according to natural sort order of the value returned by specified [selector](../../kotlin.collections/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?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortByDescending](../../kotlin.collections/sort-by-descending) Sorts elements in the array in-place descending according to natural sort order of the value returned by specified [selector](../../kotlin.collections/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?) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.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) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun <T : Comparable<T>> Array<out T>.sorted(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayWith](../../kotlin.collections/sorted-array-with) Returns an array with all elements of this array sorted according the specified [comparator](../../kotlin.collections/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](../../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.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> ``` **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.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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/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> ``` **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.Array((kotlin.collections.sortedWith.T)),%20kotlin.Comparator((kotlin.collections.sortedWith.T)))/comparator). ``` fun <T> Array<out T>.sortedWith(     comparator: Comparator<in T> ): List<T> ``` **Platform and version requirements:** JVM (1.0) #### [sortWith](../../kotlin.collections/sort-with) Sorts the array in-place according to the order specified by the given [comparator](../../kotlin.collections/sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)))/comparator). ``` fun <T> Array<out T>.sortWith(comparator: Comparator<in T>) ``` Sorts a range in the array in-place with the given [comparator](../../kotlin.collections/sort-with#kotlin.collections%24sortWith(kotlin.Array((kotlin.collections.sortWith.T)),%20java.util.Comparator((kotlin.collections.sortWith.T)),%20kotlin.Int,%20kotlin.Int)/comparator). ``` fun <T> Array<out T>.sortWith(     comparator: Comparator<in T>,     fromIndex: Int = 0,     toIndex: Int = size) ``` **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 array and not contained by the specified collection. ``` infix fun <T> Array<out T>.subtract(     other: Iterable<T> ): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/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 Array<out UInt>.sum(): UInt ``` ``` fun Array<out ULong>.sum(): ULong ``` ``` fun Array<out UByte>.sum(): UInt ``` ``` fun Array<out UShort>.sum(): UInt ``` **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.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 ``` **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.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 ``` **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.Array((kotlin.collections.sumOf.T)),%20kotlin.Function1((kotlin.collections.sumOf.T,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <T> any_array<T>.sumOf(selector: (T) -> Double): Double ``` **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.Array((kotlin.collections.take.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out 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.Array((kotlin.collections.takeLast.T)),%20kotlin.Int)/n) elements. ``` fun <T> Array<out 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.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> ``` **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.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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toBooleanArray](../../kotlin.collections/to-boolean-array) Returns an array of Boolean containing all of the elements of this generic array. ``` fun Array<out Boolean>.toBooleanArray(): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByteArray](../../kotlin.collections/to-byte-array) Returns an array of Byte containing all of the elements of this generic array. ``` fun Array<out Byte>.toByteArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCharArray](../../kotlin.collections/to-char-array) Returns an array of Char containing all of the elements of this generic array. ``` fun Array<out Char>.toCharArray(): CharArray ``` **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.Array((kotlin.collections.toCollection.T)),%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <T, C : MutableCollection<in T>> Array<out T>.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCStringArray](../../kotlinx.cinterop/to-c-string-array) Convert this array 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 Array<String>.toCStringArray(     autofreeScope: AutofreeScope ): CPointer<CPointerVar<ByteVar>> ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun <T : CPointed> Array<CPointer<T>?>.toCValues(): CValues<CPointerVar<T>> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDoubleArray](../../kotlin.collections/to-double-array) Returns an array of Double containing all of the elements of this generic array. ``` fun Array<out Double>.toDoubleArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloatArray](../../kotlin.collections/to-float-array) Returns an array of Float containing all of the elements of this generic array. ``` fun Array<out Float>.toFloatArray(): FloatArray ``` **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> Array<out T>.toHashSet(): HashSet<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toIntArray](../../kotlin.collections/to-int-array) Returns an array of Int containing all of the elements of this generic array. ``` fun Array<out Int>.toIntArray(): IntArray ``` **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> Array<out T>.toList(): List<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLongArray](../../kotlin.collections/to-long-array) Returns an array of Long containing all of the elements of this generic array. ``` fun Array<out Long>.toLongArray(): LongArray ``` **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 array of pairs. ``` fun <K, V> Array<out Pair<K, V>>.toMap(): Map<K, V> ``` Populates and returns the [destination](../../kotlin.collections/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun <T> Array<out T>.toMutableList(): MutableList<T> ``` **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 array. ``` fun <T> Array<out 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> Array<out T>.toSet(): Set<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShortArray](../../kotlin.collections/to-short-array) Returns an array of Short containing all of the elements of this generic array. ``` fun Array<out Short>.toShortArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/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>> any_array<T>.toSortedSet(): SortedSet<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../../kotlin.collections/to-u-byte-array) Returns an array of UByte containing all of the elements of this generic array. ``` fun Array<out UByte>.toUByteArray(): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../../kotlin.collections/to-u-int-array) Returns an array of UInt containing all of the elements of this generic array. ``` fun Array<out UInt>.toUIntArray(): UIntArray ``` **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 generic array. ``` fun Array<out ULong>.toULongArray(): ULongArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../../kotlin.collections/to-u-short-array) Returns an array of UShort containing all of the elements of this generic array. ``` fun Array<out UShort>.toUShortArray(): UShortArray ``` **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> Array<out 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 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>> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun <T> Array<out 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` array and the [other](../../kotlin.collections/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>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/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](../../kotlin.collections/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> ``` Returns a list of pairs built from the elements of `this` collection and [other](../../kotlin.collections/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>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/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](../../kotlin.collections/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> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): Iterator<T> ``` Creates an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator) for iterating over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(size: Int, init: (Int) -> T) ``` Creates a new array with the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: T) ``` ##### For Common, JVM, JS Sets the array element at the specified [index](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/index) to the specified [value](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/value). This method can be called using the index operator. ``` arr[index] = value ``` If the [index](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/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. ##### For Native Sets the array element at the specified [index](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/index) to the specified [value](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/value). This method can be called using the index operator. ``` arr[index] = value ``` If the [index](set#kotlin.Array%24set(kotlin.Int,%20kotlin.Array.T)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Array](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): T ``` ##### For Common, JVM, JS Returns the array element at the specified [index](get#kotlin.Array%24get(kotlin.Int)/index). This method can be called using the index operator. ``` value = arr[index] ``` If the [index](get#kotlin.Array%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. ##### For Native Returns the array element at the specified [index](get#kotlin.Array%24get(kotlin.Int)/index). This method can be called using the index operator. ``` value = arr[index] ``` If the [index](get#kotlin.Array%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin DeprecatedSinceKotlin DeprecatedSinceKotlin ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecatedSinceKotlin](index) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.TYPEALIAS]) annotation class DeprecatedSinceKotlin ``` Marks the annotated declaration as deprecated. In contrast to [Deprecated](../-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Marks the annotated declaration as deprecated. In contrast to [Deprecated](../-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. ``` <init>(     warningSince: String = "",     errorSince: String = "",     hiddenSince: String = "") ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [errorSince](error-since) the version, since which this deprecation should be reported as a error. ``` val errorSince: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [hiddenSince](hidden-since) the version, since which the annotated declaration should not be available in code. ``` val hiddenSince: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [warningSince](warning-since) the version, since which this deprecation should be reported as a warning. ``` val warningSince: String ``` 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 warningSince warningSince ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecatedSinceKotlin](index) / [warningSince](warning-since) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val warningSince: String ``` the version, since which this deprecation should be reported as a warning. Property -------- `warningSince` - the version, since which this deprecation should be reported as a warning. kotlin errorSince errorSince ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecatedSinceKotlin](index) / [errorSince](error-since) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val errorSince: String ``` the version, since which this deprecation should be reported as a error. Property -------- `errorSince` - the version, since which this deprecation should be reported as a error. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecatedSinceKotlin](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(     warningSince: String = "",     errorSince: String = "",     hiddenSince: String = "") ``` Marks the annotated declaration as deprecated. In contrast to [Deprecated](../-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. kotlin hiddenSince hiddenSince =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecatedSinceKotlin](index) / [hiddenSince](hidden-since) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val hiddenSince: String ``` the version, since which the annotated declaration should not be available in code. Property -------- `hiddenSince` - the version, since which the annotated declaration should not be available in code. kotlin packageName packageName =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [packageName](package-name) **Platform and version requirements:** JVM (1.2) ``` val packageName: String ``` Fully qualified name of the package this class is located in, from Kotlin's point of view, or empty string if this name does not differ from the JVM's package FQ name. These names can be different in case the JvmPackageName annotation is used. Note that this information is also stored in the corresponding module's `.kotlin_module` file. kotlin Metadata Metadata ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) **Platform and version requirements:** JVM (1.3) ``` @Target([AnnotationTarget.CLASS]) annotation class Metadata ``` This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. ``` Metadata(     kind: Int = 1,     metadataVersion: IntArray = [],     bytecodeVersion: IntArray = [1, 0, 3],     data1: Array<String> = [],     data2: Array<String> = [],     extraString: String = "",     packageName: String = "",     extraInt: Int = 0) ``` Properties ---------- **Platform and version requirements:** JVM (1.0) #### [bytecodeVersion](bytecode-version) The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation. ``` val bytecodeVersion: IntArray ``` **Platform and version requirements:** JVM (1.0) #### <data1> Metadata in a custom format. The format may be different (or even absent) for different kinds. ``` val data1: Array<String> ``` **Platform and version requirements:** JVM (1.0) #### <data2> An addition to <data1>: array of strings which occur in metadata, written in plain text so that strings already present in the constant pool are reused. These strings may be then indexed in the metadata by an integer index in this array. ``` val data2: Array<String> ``` **Platform and version requirements:** JVM (1.1) #### [extraInt](extra-int) An extra int. Bits of this number represent the following flags: ``` val extraInt: Int ``` **Platform and version requirements:** JVM (1.0) #### [extraString](extra-string) An extra string. For a multi-file part class, internal name of the facade class. ``` val extraString: String ``` **Platform and version requirements:** JVM (1.0) #### <kind> A kind of the metadata this annotation encodes. Kotlin compiler recognizes the following kinds (see KotlinClassHeader.Kind): ``` val kind: Int ``` **Platform and version requirements:** JVM (1.0) #### [metadataVersion](metadata-version) The version of the metadata provided in the arguments of this annotation. ``` val metadataVersion: IntArray ``` **Platform and version requirements:** JVM (1.2) #### [packageName](package-name) Fully qualified name of the package this class is located in, from Kotlin's point of view, or empty string if this name does not differ from the JVM's package FQ name. These names can be different in case the JvmPackageName annotation is used. Note that this information is also stored in the corresponding module's `.kotlin_module` file. ``` val packageName: String ``` 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 data2 data2 ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / <data2> **Platform and version requirements:** JVM (1.0) ``` val data2: Array<String> ``` An addition to <data1>: array of strings which occur in metadata, written in plain text so that strings already present in the constant pool are reused. These strings may be then indexed in the metadata by an integer index in this array. kotlin extraString extraString =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [extraString](extra-string) **Platform and version requirements:** JVM (1.0) ``` val extraString: String ``` An extra string. For a multi-file part class, internal name of the facade class. kotlin kind kind ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / <kind> **Platform and version requirements:** JVM (1.0) ``` val kind: Int ``` A kind of the metadata this annotation encodes. Kotlin compiler recognizes the following kinds (see KotlinClassHeader.Kind): 1 Class 2 File 3 Synthetic class 4 Multi-file class facade 5 Multi-file class part The class file with a kind not listed here is treated as a non-Kotlin file. kotlin extraInt extraInt ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [extraInt](extra-int) **Platform and version requirements:** JVM (1.1) ``` val extraInt: Int ``` An extra int. Bits of this number represent the following flags: * 0 - this is a multi-file class facade or part, compiled with `-Xmultifile-parts-inherit`. * 1 - this class file is compiled by a pre-release version of Kotlin and is not visible to release versions. * 2 - this class file is a compiled Kotlin script source file (.kts). * 3 - "strict metadata version semantics". The metadata of this class file is not supposed to be read by the compiler, whose major.minor version is less than the major.minor version of this metadata ([metadataVersion](metadata-version)). * 4 - this class file is compiled with the new Kotlin compiler backend (JVM IR) introduced in Kotlin 1.4. * 5 - this class file has stable metadata and ABI. This is used only for class files compiled with JVM IR (see flag #4) or FIR (#6), and prevents metadata incompatibility diagnostics from being reported where the class is used. * 6 - this class file is compiled with the new Kotlin compiler frontend (FIR). * 7 - this class is used in the scope of an inline function and implicitly part of the public ABI. Only valid from metadata version 1.6.0. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` Metadata(     kind: Int = 1,     metadataVersion: IntArray = [],     bytecodeVersion: IntArray = [1, 0, 3],     data1: Array<String> = [],     data2: Array<String> = [],     extraString: String = "",     packageName: String = "",     extraInt: Int = 0) ``` This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. kotlin metadataVersion metadataVersion =============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [metadataVersion](metadata-version) **Platform and version requirements:** JVM (1.0) ``` val metadataVersion: IntArray ``` The version of the metadata provided in the arguments of this annotation. kotlin data1 data1 ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / <data1> **Platform and version requirements:** JVM (1.0) ``` val data1: Array<String> ``` Metadata in a custom format. The format may be different (or even absent) for different kinds. kotlin bytecodeVersion bytecodeVersion =============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Metadata](index) / [bytecodeVersion](bytecode-version) **Platform and version requirements:** JVM (1.0) ``` val bytecodeVersion: IntArray ``` **Deprecated:** Bytecode version had no significant use in Kotlin metadata and it will be removed in a future version. The version of the bytecode interface (naming conventions, signatures) of the class file annotated with this annotation. kotlin SYNCHRONIZED SYNCHRONIZED ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LazyThreadSafetyMode](index) / [SYNCHRONIZED](-s-y-n-c-h-r-o-n-i-z-e-d) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` SYNCHRONIZED ``` Locks are used to ensure that only a single thread can initialize the [Lazy](../-lazy/index) instance. kotlin LazyThreadSafetyMode LazyThreadSafetyMode ==================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LazyThreadSafetyMode](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` enum class LazyThreadSafetyMode ``` Specifies how a [Lazy](../-lazy/index) instance synchronizes initialization among multiple threads. Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SYNCHRONIZED](-s-y-n-c-h-r-o-n-i-z-e-d) Locks are used to ensure that only a single thread can initialize the [Lazy](../-lazy/index) instance. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [PUBLICATION](-p-u-b-l-i-c-a-t-i-o-n) Initializer function can be called several times on concurrent access to uninitialized [Lazy](../-lazy/index) instance value, but only the first returned value will be used as the value of [Lazy](../-lazy/index) instance. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NONE](-n-o-n-e) No locks are used to synchronize an access to the [Lazy](../-lazy/index) instance value; if the instance is accessed from multiple threads, its behavior is undefined. 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** 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> ```
programming_docs
kotlin PUBLICATION PUBLICATION =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LazyThreadSafetyMode](index) / [PUBLICATION](-p-u-b-l-i-c-a-t-i-o-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` PUBLICATION ``` Initializer function can be called several times on concurrent access to uninitialized [Lazy](../-lazy/index) instance value, but only the first returned value will be used as the value of [Lazy](../-lazy/index) instance. kotlin NONE NONE ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LazyThreadSafetyMode](index) / [NONE](-n-o-n-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` NONE ``` No locks are used to synchronize an access to the [Lazy](../-lazy/index) instance value; if the instance is accessed from multiple threads, its behavior is undefined. This mode should not be used unless the [Lazy](../-lazy/index) instance is guaranteed never to be initialized from more than one thread. kotlin Extensions for java.math.BigDecimal Extensions for java.math.BigDecimal =================================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) **Platform and version requirements:** JVM (1.2) #### <dec> Enables the use of the unary `--` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.dec(): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### <div> Enables the use of the `/` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.div(other: BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.2) #### <inc> Enables the use of the unary `++` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.inc(): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### <minus> Enables the use of the `-` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.minus(other: BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### <plus> Enables the use of the `+` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.plus(other: BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### <rem> Enables the use of the `%` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.rem(other: BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### <times> Enables the use of the `*` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.times(other: BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### [unaryMinus](unary-minus) Enables the use of the unary `-` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. ``` operator fun BigDecimal.unaryMinus(): BigDecimal ``` kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <rem> **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.rem(other: BigDecimal): BigDecimal ``` Enables the use of the `%` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <div> **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.div(other: BigDecimal): BigDecimal ``` Enables the use of the `/` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. The scale of the result is the same as the scale of `this` (divident), and for rounding the [RoundingMode.HALF\_EVEN](https://docs.oracle.com/javase/8/docs/api/java/math/RoundingMode.html#HALF_EVEN) rounding mode is used. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <dec> **Platform and version requirements:** JVM (1.2) ``` operator fun BigDecimal.dec(): BigDecimal ``` Enables the use of the unary `--` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <inc> **Platform and version requirements:** JVM (1.2) ``` operator fun BigDecimal.inc(): BigDecimal ``` Enables the use of the unary `++` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin unaryMinus unaryMinus ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.unaryMinus(): BigDecimal ``` Enables the use of the unary `-` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <times> **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.times(other: BigDecimal): BigDecimal ``` Enables the use of the `*` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <minus> **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.minus(other: BigDecimal): BigDecimal ``` Enables the use of the `-` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigDecimal](index) / <plus> **Platform and version requirements:** JVM (1.0) ``` operator fun BigDecimal.plus(other: BigDecimal): BigDecimal ``` Enables the use of the `+` operator for [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) instances. kotlin ParameterName ParameterName ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ParameterName](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @Target([AnnotationTarget.TYPE]) annotation class ParameterName ``` Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). ``` <init>(name: String) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <name> ``` val name: String ``` 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) / [ParameterName](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(name: String) ``` Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ParameterName](index) / <name> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val name: String ``` kotlin OutOfMemoryError OutOfMemoryError ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OutOfMemoryError](index) **Platform and version requirements:** Native (1.3) ``` open class OutOfMemoryError : Error ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` OutOfMemoryError() ``` ``` OutOfMemoryError(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) / [OutOfMemoryError](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` OutOfMemoryError() ``` ``` OutOfMemoryError(message: String?) ``` kotlin compare compare ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Comparator](index) / <compare> **Platform and version requirements:** JS (1.1), Native (1.3) ``` abstract fun compare(a: T, b: T): Int ``` Compares its two arguments for order. Returns zero if the arguments are equal, a negative number if the first argument is less than the second, or a positive number if the first argument is greater than the second. kotlin Comparator Comparator ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Comparator](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun interface Comparator<T> ``` **Platform and version requirements:** JVM (1.1) ``` typealias Comparator<T> = Comparator<T> ``` Provides a comparison function for imposing a total ordering between instances of the type [T](index#T). Functions --------- **Platform and version requirements:** JS (1.0), Native (1.0) #### <compare> Compares its two arguments for order. Returns zero if the arguments are equal, a negative number if the first argument is less than the second, or a positive number if the first argument is greater than the second. ``` abstract fun compare(a: T, b: T): Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../../kotlin.comparisons/reversed) Returns a comparator that imposes the reverse ordering of this comparator. ``` fun <T> Comparator<T>.reversed(): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [then](../../kotlin.comparisons/then) Combines this comparator and the given [comparator](../../kotlin.comparisons/then#kotlin.comparisons%24then(kotlin.Comparator((kotlin.comparisons.then.T)),%20kotlin.Comparator((kotlin.comparisons.then.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` infix fun <T> Comparator<T>.then(     comparator: Comparator<in T> ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenBy](../../kotlin.comparisons/then-by) Creates a comparator comparing values after the primary comparator defined them equal. It uses the function to transform value to a [Comparable](../-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> Comparator<T>.thenBy(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a comparator comparing values after the primary comparator defined them equal. It uses the [selector](../../kotlin.comparisons/then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/selector) function to transform values and then compares them with the given [comparator](../../kotlin.comparisons/then-by#kotlin.comparisons%24thenBy(kotlin.Comparator((kotlin.comparisons.thenBy.T)),%20kotlin.Comparator((kotlin.comparisons.thenBy.K)),%20kotlin.Function1((kotlin.comparisons.thenBy.T,%20kotlin.comparisons.thenBy.K)))/comparator). ``` fun <T, K> Comparator<T>.thenBy(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenByDescending](../../kotlin.comparisons/then-by-descending) Creates a descending comparator using the primary comparator and the function to transform value to a [Comparable](../-comparable/index#kotlin.Comparable) instance for comparison. ``` fun <T> Comparator<T>.thenByDescending(     selector: (T) -> Comparable<*>? ): Comparator<T> ``` Creates a descending comparator comparing values after the primary comparator defined them equal. It uses the [selector](../../kotlin.comparisons/then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/selector) function to transform values and then compares them with the given [comparator](../../kotlin.comparisons/then-by-descending#kotlin.comparisons%24thenByDescending(kotlin.Comparator((kotlin.comparisons.thenByDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenByDescending.K)),%20kotlin.Function1((kotlin.comparisons.thenByDescending.T,%20kotlin.comparisons.thenByDescending.K)))/comparator). ``` fun <T, K> Comparator<T>.thenByDescending(     comparator: Comparator<in K>,     selector: (T) -> K ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenComparator](../../kotlin.comparisons/then-comparator) Creates a comparator using the primary comparator and function to calculate a result of comparison. ``` fun <T> Comparator<T>.thenComparator(     comparison: (a: T, b: T) -> Int ): Comparator<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [thenDescending](../../kotlin.comparisons/then-descending) Combines this comparator and the given [comparator](../../kotlin.comparisons/then-descending#kotlin.comparisons%24thenDescending(kotlin.Comparator((kotlin.comparisons.thenDescending.T)),%20kotlin.Comparator((kotlin.comparisons.thenDescending.T)))/comparator) such that the latter is applied only when the former considered values equal. ``` infix fun <T> Comparator<T>.thenDescending(     comparator: Comparator<in T> ): Comparator<T> ``` kotlin OptIn OptIn ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OptIn](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE, AnnotationTarget.TYPEALIAS]) annotation class OptIn ``` Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](index), its usages are **not** required to opt in to that API. [markerClass](marker-class) specifies marker annotations that require explicit opt-in. The marker annotation is not required to be itself marked with [RequiresOptIn](../-requires-opt-in/index) to enable gradual migration of API from requiring opt-in to the regular one, yet declaring such `OptIn` yields a compilation warning. See also [Kotlin language documentation](../../../../../../docs/opt-in-requirements) for more information. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](index), its usages are **not** required to opt in to that API. ``` OptIn(vararg markerClass: KClass<out Annotation>) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [markerClass](marker-class) specifies marker annotations that require explicit opt-in. ``` vararg val markerClass: Array<out KClass<out Annotation>> ``` kotlin markerClass markerClass =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OptIn](index) / [markerClass](marker-class) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` vararg val markerClass: Array<out KClass<out Annotation>> ``` specifies marker annotations that require explicit opt-in. Property -------- `markerClass` - specifies marker annotations that require explicit opt-in. **See Also** [RequiresOptIn](../-requires-opt-in/index) kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [OptIn](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` OptIn(vararg markerClass: KClass<out Annotation>) ``` Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](index), its usages are **not** required to opt in to that API. [markerClass](marker-class) specifies marker annotations that require explicit opt-in. The marker annotation is not required to be itself marked with [RequiresOptIn](../-requires-opt-in/index) to enable gradual migration of API from requiring opt-in to the regular one, yet declaring such `OptIn` yields a compilation warning. See also [Kotlin language documentation](../../../../../../docs/opt-in-requirements) for more information. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin IntArray IntArray ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class IntArray ``` An array of ints. When targeting the JVM, instances of this class are represented as `int[]`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Int) ``` Creates a new array of the specified [size](size#kotlin.IntArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.IntArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Int ``` **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(): IntIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/index) to the given [value](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Int) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val IntArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val IntArray.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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.all(predicate: (Int) -> 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 IntArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.any(predicate: (Int) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun IntArray.asIterable(): Iterable<Int> ``` **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 array returning its elements when being iterated. ``` fun IntArray.asSequence(): Sequence<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> IntArray.associate(     transform: (Int) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> IntArray.associateBy(     keySelector: (Int) -> K ): Map<K, Int> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> IntArray.associateBy(     keySelector: (Int) -> K,     valueTransform: (Int) -> 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.IntArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Int>> IntArray.associateByTo(     destination: M,     keySelector: (Int) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.IntArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.IntArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> IntArray.associateByTo(     destination: M,     keySelector: (Int) -> K,     valueTransform: (Int) -> 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.IntArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> IntArray.associateTo(     destination: M,     transform: (Int) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> IntArray.associateWith(     valueSelector: (Int) -> V ): Map<Int, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.IntArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Int, in V>> IntArray.associateWithTo(     destination: M,     valueSelector: (Int) -> V ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUIntArray](../../kotlin.collections/as-u-int-array) Returns an array of type [UIntArray](../-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.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun IntArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.IntArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun IntArray.binarySearch(     element: Int,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun IntArray.component1(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun IntArray.component2(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun IntArray.component3(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun IntArray.component4(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun IntArray.component5(): Int ``` **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.IntArray,%20kotlin.Int)/element) is found in the array. ``` operator fun IntArray.contains(element: Int): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun IntArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.count(predicate: (Int) -> 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 array. ``` fun IntArray.distinct(): List<Int> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> IntArray.distinctBy(selector: (Int) -> K): List<Int> ``` **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.IntArray,%20kotlin.Int)/n) elements. ``` fun IntArray.drop(n: Int): List<Int> ``` **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.IntArray,%20kotlin.Int)/n) elements. ``` fun IntArray.dropLast(n: Int): List<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.dropLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.dropWhile(     predicate: (Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/index) is out of bounds of this array. ``` fun IntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.IntArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.IntArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun IntArray.elementAtOrNull(index: Int): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.filter(predicate: (Int) -> Boolean): List<Int> ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.Boolean)))/predicate). ``` fun IntArray.filterIndexed(     predicate: (index: Int, Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.IntArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Int>> IntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Int) -> Boolean ): 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.filterNot(     predicate: (Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.IntArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Int>> IntArray.filterNotTo(     destination: C,     predicate: (Int) -> 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.IntArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.IntArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Int>> IntArray.filterTo(     destination: C,     predicate: (Int) -> 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun IntArray.find(predicate: (Int) -> Boolean): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun IntArray.findLast(predicate: (Int) -> Boolean): Int? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun IntArray.first(): Int ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.first(predicate: (Int) -> Boolean): Int ``` **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 IntArray.firstOrNull(): Int? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun IntArray.firstOrNull(predicate: (Int) -> Boolean): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> IntArray.flatMap(     transform: (Int) -> Iterable<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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> IntArray.flatMapIndexed(     transform: (index: Int, Int) -> Iterable<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.IntArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%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.IntArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> IntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Int) -> Iterable<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.IntArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> IntArray.flatMapTo(     destination: C,     transform: (Int) -> Iterable<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.IntArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Int,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.IntArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Int,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> IntArray.fold(     initial: R,     operation: (acc: R, Int) -> 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.IntArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.IntArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> IntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> 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.IntArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.IntArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Int,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> IntArray.foldRight(     initial: R,     operation: (Int, 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.IntArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.IntArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20,%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> IntArray.foldRightIndexed(     initial: R,     operation: (index: Int, Int, 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/action) on each element. ``` fun IntArray.forEach(action: (Int) -> 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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun IntArray.forEachIndexed(     action: (index: Int, Int) -> 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.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.IntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20)))/index) is out of bounds of this array. ``` fun IntArray.getOrElse(     index: Int,     defaultValue: (Int) -> Int ): Int ``` **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.IntArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.IntArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun IntArray.getOrNull(index: Int): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%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> IntArray.groupBy(     keySelector: (Int) -> K ): Map<K, List<Int>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Int,%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> IntArray.groupBy(     keySelector: (Int) -> K,     valueTransform: (Int) -> 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.IntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.IntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Int>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.IntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.IntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Int,%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>>> IntArray.groupByTo(     destination: M,     keySelector: (Int) -> K,     valueTransform: (Int) -> V ): M ``` **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.IntArray,%20kotlin.Int)/element), or -1 if the array does not contain element. ``` fun IntArray.indexOf(element: Int): 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun IntArray.indexOfFirst(predicate: (Int) -> 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun IntArray.indexOfLast(predicate: (Int) -> 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 array and the specified collection. ``` infix fun IntArray.intersect(other: Iterable<Int>): Set<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun IntArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun IntArray.isNotEmpty(): 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.IntArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.IntArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.IntArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> IntArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> 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.IntArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.IntArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.IntArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Int,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun IntArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Int) -> 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 IntArray.last(): Int ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.last(predicate: (Int) -> Boolean): Int ``` **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.IntArray,%20kotlin.Int)/element), or -1 if the array does not contain element. ``` fun IntArray.lastIndexOf(element: Int): 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 IntArray.lastOrNull(): Int? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun IntArray.lastOrNull(predicate: (Int) -> Boolean): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> IntArray.map(transform: (Int) -> 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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> IntArray.mapIndexed(     transform: (index: Int, Int) -> R ): List<R> ``` **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.IntArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%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.IntArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> IntArray.mapIndexedTo(     destination: C,     transform: (index: Int, Int) -> 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.IntArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Int,%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.IntArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> IntArray.mapTo(     destination: C,     transform: (Int) -> 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>> IntArray.maxByOrNull(     selector: (Int) -> R ): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Int) -> 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Int) -> 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.IntArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.IntArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> IntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Int) -> 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.IntArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.IntArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> IntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> 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 IntArray.maxOrNull(): Int? ``` #### [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.IntArray,%20kotlin.Comparator((kotlin.Int)))/comparator). ``` fun IntArray.maxWith(comparator: Comparator<in Int>): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun IntArray.maxWith(comparator: Comparator<in Int>): Int? ``` **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.IntArray,%20kotlin.Comparator((kotlin.Int)))/comparator) or `null` if there are no elements. ``` fun IntArray.maxWithOrNull(     comparator: Comparator<in Int> ): Int? ``` **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>> IntArray.minByOrNull(     selector: (Int) -> R ): Int? ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Int) -> 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Int) -> 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.IntArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.IntArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> IntArray.minOfWith(     comparator: Comparator<in R>,     selector: (Int) -> 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.IntArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.IntArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Int,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> IntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Int) -> 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 IntArray.minOrNull(): Int? ``` #### [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.IntArray,%20kotlin.Comparator((kotlin.Int)))/comparator). ``` fun IntArray.minWith(comparator: Comparator<in Int>): Int ``` **Platform and version requirements:** JVM (1.0) ``` fun IntArray.minWith(comparator: Comparator<in Int>): Int? ``` **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.IntArray,%20kotlin.Comparator((kotlin.Int)))/comparator) or `null` if there are no elements. ``` fun IntArray.minWithOrNull(     comparator: Comparator<in Int> ): Int? ``` **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 IntArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.none(predicate: (Int) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun IntArray.onEach(action: (Int) -> Unit): IntArray ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun IntArray.onEachIndexed(     action: (index: Int, Int) -> Unit ): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun IntArray.partition(     predicate: (Int) -> Boolean ): Pair<List<Int>, List<Int>> ``` **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 IntArray.random(): Int ``` Returns a random element from this array using the specified source of randomness. ``` fun IntArray.random(random: Random): Int ``` **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 IntArray.randomOrNull(): Int? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun IntArray.randomOrNull(random: Random): Int? ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun IntArray.reduce(operation: (acc: Int, Int) -> Int): Int ``` **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.IntArray,%20kotlin.Function3((kotlin.Int,%20,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun IntArray.reduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): Int ``` **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.IntArray,%20kotlin.Function3((kotlin.Int,%20,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun IntArray.reduceIndexedOrNull(     operation: (index: Int, acc: Int, Int) -> Int ): Int? ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun IntArray.reduceOrNull(     operation: (acc: Int, Int) -> Int ): Int? ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun IntArray.reduceRight(     operation: (Int, acc: Int) -> Int ): Int ``` **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.IntArray,%20kotlin.Function3((kotlin.Int,%20,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun IntArray.reduceRightIndexed(     operation: (index: Int, Int, acc: Int) -> Int ): Int ``` **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.IntArray,%20kotlin.Function3((kotlin.Int,%20,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun IntArray.reduceRightIndexedOrNull(     operation: (index: Int, Int, acc: Int) -> Int ): Int? ``` **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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun IntArray.reduceRightOrNull(     operation: (Int, acc: Int) -> Int ): Int? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun IntArray.refTo(index: Int): CValuesRef<IntVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun IntArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun IntArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 IntArray.reversed(): List<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun IntArray.reversedArray(): IntArray ``` **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.IntArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Int,%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.IntArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Int,%20)))/initial) value. ``` fun <R> IntArray.runningFold(     initial: R,     operation: (acc: R, Int) -> 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.IntArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20,%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.IntArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20,%20)))/initial) value. ``` fun <R> IntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> 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.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun IntArray.runningReduce(     operation: (acc: Int, Int) -> Int ): List<Int> ``` **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.IntArray,%20kotlin.Function3((kotlin.Int,%20,%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 IntArray.runningReduceIndexed(     operation: (index: Int, acc: Int, Int) -> Int ): List<Int> ``` **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.IntArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Int,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.IntArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Int,%20)))/initial) value. ``` fun <R> IntArray.scan(     initial: R,     operation: (acc: R, Int) -> 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.IntArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20,%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.IntArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20,%20)))/initial) value. ``` fun <R> IntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Int) -> 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 IntArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.IntArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun IntArray.shuffle(random: Random) ``` **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 IntArray.single(): Int ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun IntArray.single(predicate: (Int) -> Boolean): Int ``` **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 IntArray.singleOrNull(): Int? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun IntArray.singleOrNull(predicate: (Int) -> Boolean): Int? ``` **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.IntArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun IntArray.slice(indices: IntRange): List<Int> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.IntArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun IntArray.slice(indices: Iterable<Int>): List<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.IntArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun IntArray.sliceArray(indices: Collection<Int>): IntArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.IntArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun IntArray.sliceArray(indices: IntRange): IntArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20)))/comparison) function. ``` fun IntArray.sort(comparison: (a: Int, b: Int) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun IntArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun IntArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun IntArray.sorted(): List<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun IntArray.sortedArray(): IntArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun IntArray.sortedArrayDescending(): IntArray ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> IntArray.sortedBy(     selector: (Int) -> R? ): List<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> IntArray.sortedByDescending(     selector: (Int) -> R? ): List<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun IntArray.sortedDescending(): List<Int> ``` **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.IntArray,%20kotlin.Comparator((kotlin.Int)))/comparator). ``` fun IntArray.sortedWith(     comparator: Comparator<in Int> ): List<Int> ``` **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 array and not contained by the specified collection. ``` infix fun IntArray.subtract(other: Iterable<Int>): Set<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun IntArray.sum(): Int ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20)))/selector) function applied to each element in the array. ``` fun IntArray.sumBy(selector: (Int) -> 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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun IntArray.sumByDouble(selector: (Int) -> Double): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.IntArray,%20kotlin.Function1((kotlin.Int,%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 IntArray.sumOf(selector: (Int) -> Double): Double ``` **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 IntArray.sumOf(selector: (Int) -> Long): Long ``` **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 IntArray.sumOf(selector: (Int) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun IntArray.sumOf(selector: (Int) -> BigDecimal): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun IntArray.sumOf(selector: (Int) -> BigInteger): BigInteger ``` **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.IntArray,%20kotlin.Int)/n) elements. ``` fun IntArray.take(n: Int): List<Int> ``` **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.IntArray,%20kotlin.Int)/n) elements. ``` fun IntArray.takeLast(n: Int): List<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.takeLastWhile(     predicate: (Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/predicate). ``` fun IntArray.takeWhile(     predicate: (Int) -> Boolean ): List<Int> ``` **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.IntArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Int>> IntArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun IntArray.toCValues(): CValues<IntVar> ``` **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 IntArray.toHashSet(): HashSet<Int> ``` **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 IntArray.toList(): List<Int> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun IntArray.toMutableList(): MutableList<Int> ``` **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 array. ``` fun IntArray.toMutableSet(): MutableSet<Int> ``` **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 IntArray.toSet(): Set<Int> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun IntArray.toSortedSet(): SortedSet<Int> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../../kotlin.collections/to-u-int-array) Returns an array of type [UIntArray](../-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 ``` **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 IntArray.union(other: Iterable<Int>): Set<Int> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun IntArray.withIndex(): Iterable<IndexedValue<Int>> ``` **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.IntArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Int, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.IntArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Int,%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.IntArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Int,%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> IntArray.zip(     other: Array<out R>,     transform: (a: Int, 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.IntArray,%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> IntArray.zip(     other: Iterable<R> ): List<Pair<Int, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.IntArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Int,%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.IntArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Int,%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> IntArray.zip(     other: Iterable<R>,     transform: (a: Int, 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.IntArray,%20kotlin.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.IntArray,%20kotlin.IntArray,%20kotlin.Function2((kotlin.Int,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> IntArray.zip(     other: IntArray,     transform: (a: Int, b: Int) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): IntIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Int) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.IntArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.IntArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Int) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/index) to the given [value](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/value). This method can be called using the index operator. If the [index](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.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. ##### For Native Sets the element at the given [index](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/index) to the given [value](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/value). This method can be called using the index operator. If the [index](set#kotlin.IntArray%24set(kotlin.Int,%20kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IntArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Int ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.IntArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.IntArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.IntArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.IntArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin CharSequence CharSequence ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharSequence](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface CharSequence ``` Represents a readable sequence of [Char](../-char/index#kotlin.Char) values. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <length> Returns the length of this character sequence. ``` abstract val length: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the character at the specified [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) in this character sequence. ``` abstract operator fun get(index: Int): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subSequence](sub-sequence) Returns a new character sequence that is a subsequence of this character sequence, starting at the specified [startIndex](sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the specified [endIndex](sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/endIndex). ``` abstract fun subSequence(     startIndex: Int,     endIndex: Int ): CharSequence ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.text/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](../../kotlin.text/last-index) Returns the index of the last character in the char sequence or -1 if it is empty. ``` val CharSequence.lastIndex: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../../kotlin.text/all) Returns `true` if all characters match the given [predicate](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [asIterable](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-by-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-with-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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.2), JS (1.2), Native (1.2) #### [chunked](../../kotlin.text/chunked) Splits this char sequence into a list of strings each not exceeding the given [size](../../kotlin.text/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](../../kotlin.text/chunked#kotlin.text%24chunked(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunked.R)))/size) and applies the given [transform](../../kotlin.text/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](../../kotlin.text/chunked-sequence) Splits this char sequence into a sequence of strings each not exceeding the given [size](../../kotlin.text/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](../../kotlin.text/chunked-sequence#kotlin.text%24chunkedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunkedSequence.R)))/size) and applies the given [transform](../../kotlin.text/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:** JVM (1.0), JS (1.0), Native (1.0) #### [commonPrefixWith](../../kotlin.text/common-prefix-with) Returns the longest string `prefix` such that this char sequence and [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/common-suffix-with) Returns the longest string `suffix` such that this char sequence and [other](../../kotlin.text/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](../../kotlin.text/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) #### [contains](../../kotlin.text/contains) Returns `true` if this char sequence contains the specified [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.text.Regex)/regex). ``` operator fun CharSequence.contains(regex: Regex): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.text/count) Returns the length of this char sequence. ``` fun CharSequence.count(): Int ``` Returns the number of characters matching the given [predicate](../../kotlin.text/count#kotlin.text%24count(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.count(predicate: (Char) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [drop](../../kotlin.text/drop) Returns a subsequence of this char sequence with the first [n](../../kotlin.text/drop#kotlin.text%24drop(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` fun CharSequence.drop(n: Int): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLast](../../kotlin.text/drop-last) Returns a subsequence of this char sequence with the last [n](../../kotlin.text/drop-last#kotlin.text%24dropLast(kotlin.CharSequence,%20kotlin.Int)/n) characters removed. ``` fun CharSequence.dropLast(n: Int): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropLastWhile](../../kotlin.text/drop-last-while) Returns a subsequence of this char sequence containing all characters except last characters that satisfy the given [predicate](../../kotlin.text/drop-last-while#kotlin.text%24dropLastWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.dropLastWhile(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [dropWhile](../../kotlin.text/drop-while) Returns a subsequence of this char sequence containing all characters except first characters that satisfy the given [predicate](../../kotlin.text/drop-while#kotlin.text%24dropWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.dropWhile(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrElse](../../kotlin.text/element-at-or-else) Returns a character at the given [index](../../kotlin.text/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](../../kotlin.text/element-at-or-else#kotlin.text%24elementAtOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.text/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](../../kotlin.text/element-at-or-null) Returns a character at the given [index](../../kotlin.text/element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.text/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.0), JS (1.0), Native (1.0) #### [endsWith](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../../kotlin.text/filter) Returns a char sequence containing only those characters from the original char sequence that match the given [predicate](../../kotlin.text/filter#kotlin.text%24filter(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.filter(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexed](../../kotlin.text/filter-indexed) Returns a char sequence containing only those characters from the original char sequence that match the given [predicate](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterIndexedTo](../../kotlin.text/filter-indexed-to) Appends all characters matching the given [predicate](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/filter-not) Returns a char sequence containing only those characters from the original char sequence that do not match the given [predicate](../../kotlin.text/filter-not#kotlin.text%24filterNot(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.filterNot(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filterNotTo](../../kotlin.text/filter-not-to) Appends all characters not matching the given [predicate](../../kotlin.text/filter-not-to#kotlin.text%24filterNotTo(kotlin.CharSequence,%20kotlin.text.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.text/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](../../kotlin.text/filter-to) Appends all characters matching the given [predicate](../../kotlin.text/filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.text/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](../../kotlin.text/find) Returns the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/find-any-of) Finds the first occurrence of any of the specified [strings](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/find-last) Returns the last character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/find-last-any-of) Finds the last occurrence of any of the specified [strings](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/first) Returns the first character. ``` fun CharSequence.first(): Char ``` Returns the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/first-not-null-of) Returns the first non-null value produced by [transform](../../kotlin.text/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](../-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](../../kotlin.text/first-not-null-of-or-null) Returns the first non-null value produced by [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/flat-map) Returns a single list of all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/flat-map-indexed-to) Appends all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/flat-map-to) Appends all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold) Accumulates value starting with [initial](../../kotlin.text/fold#kotlin.text%24fold(kotlin.CharSequence,%20kotlin.text.fold.R,%20kotlin.Function2((kotlin.text.fold.R,%20kotlin.Char,%20)))/initial) value and applying [operation](../../kotlin.text/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](../../kotlin.text/fold-indexed) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold-right) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold-right-indexed) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/for-each) Performs the given [action](../../kotlin.text/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](../../kotlin.text/for-each-indexed) Performs the given [action](../../kotlin.text/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), JS (1.0), Native (1.0) #### [getOrElse](../../kotlin.text/get-or-else) Returns a character at the given [index](../../kotlin.text/get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](../../kotlin.text/get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.text/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](../../kotlin.text/get-or-null) Returns a character at the given [index](../../kotlin.text/get-or-null#kotlin.text%24getOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.text/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](../../kotlin.text/group-by) Groups characters of the original char sequence by the key returned by the given [keySelector](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/group-by-to) Groups characters of the original char sequence by the key returned by the given [keySelector](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/has-surrogate-pair-at) Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index](../../kotlin.text/has-surrogate-pair-at#kotlin.text%24hasSurrogatePairAt(kotlin.CharSequence,%20kotlin.Int)/index). ``` fun CharSequence.hasSurrogatePairAt(index: Int): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indexOf](../../kotlin.text/index-of) Returns the index within this string of the first occurrence of the specified character, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/index-of#kotlin.text%24indexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/index-of-any) Finds the index of the first occurrence of any of the specified [chars](../../kotlin.text/index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) in this char sequence, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/index-of-first) Returns index of the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/index-of-last) Returns index of the last character matching the given [predicate](../../kotlin.text/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:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.text/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) #### [isNotBlank](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [iterator](../../kotlin.text/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](../../kotlin.text/last) Returns the last character. ``` fun CharSequence.last(): Char ``` Returns the last character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/last-index-of) Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/last-index-of-any) Finds the index of the last occurrence of any of the specified [chars](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../../kotlin.text/map) Returns a list containing the results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed) Returns a list containing the results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed-not-null-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-indexed-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-not-null-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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:** JVM (1.0), JS (1.0), Native (1.0) #### [matches](../../kotlin.text/matches) Returns `true` if this char sequence matches the given regular expression. ``` infix fun CharSequence.matches(regex: Regex): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../../kotlin.text/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](../../kotlin.text/max-of) Returns the largest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/max-of-or-null) Returns the largest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/max-of-with) Returns the largest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-of-with-or-null) Returns the largest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-or-null) Returns the largest character or `null` if there are no characters. ``` fun CharSequence.maxOrNull(): Char? ``` #### [maxWith](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-with-or-null) Returns the first character having the largest value according to the provided [comparator](../../kotlin.text/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? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../../kotlin.text/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](../../kotlin.text/min-of) Returns the smallest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/min-of-or-null) Returns the smallest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/min-of-with) Returns the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-of-with-or-null) Returns the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-or-null) Returns the smallest character or `null` if there are no characters. ``` fun CharSequence.minOrNull(): Char? ``` #### [minWith](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-with-or-null) Returns the first character having the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/none) Returns `true` if the char sequence has no characters. ``` fun CharSequence.none(): Boolean ``` Returns `true` if no characters match the given [predicate](../../kotlin.text/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.1), JS (1.1), Native (1.1) #### [onEach](../../kotlin.text/on-each) Performs the given [action](../../kotlin.text/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](../../kotlin.text/on-each-indexed) Performs the given [action](../../kotlin.text/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) #### [padEnd](../../kotlin.text/pad-end) Returns a char sequence with content of this char sequence padded at the end to the specified [length](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [padStart](../../kotlin.text/pad-start) Returns a char sequence with content of this char sequence padded at the beginning to the specified [length](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.text/partition) Splits the original char sequence into pair of char sequences, where *first* char sequence contains characters for which [predicate](../../kotlin.text/partition#kotlin.text%24partition(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* char sequence contains characters for which [predicate](../../kotlin.text/partition#kotlin.text%24partition(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun CharSequence.partition(     predicate: (Char) -> Boolean ): Pair<CharSequence, CharSequence> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [random](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/reduce) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-indexed) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-indexed-or-null) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-or-null) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-indexed) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-indexed-or-null) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-or-null) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removePrefix](../../kotlin.text/remove-prefix) If this char sequence starts with the given [prefix](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeRange](../../kotlin.text/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 ``` Returns a char sequence with content of this char sequence where its part at the given [range](../../kotlin.text/remove-range#kotlin.text%24removeRange(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) is removed. ``` fun CharSequence.removeRange(range: IntRange): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeSuffix](../../kotlin.text/remove-suffix) If this char sequence ends with the given [suffix](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removeSurrounding](../../kotlin.text/remove-surrounding) When this char sequence starts with the given [prefix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and ends with the given [suffix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix), returns a new char sequence having both the given [prefix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and [suffix](../../kotlin.text/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 ``` When this char sequence starts with and ends with the given [delimiter](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.CharSequence,%20kotlin.CharSequence)/delimiter), returns a new char sequence having this [delimiter](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replace](../../kotlin.text/replace) Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given [replacement](../../kotlin.text/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](../../kotlin.text/replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.Function1((kotlin.text.MatchResult,%20kotlin.CharSequence)))/transform) that takes [MatchResult](../../kotlin.text/-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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceFirst](../../kotlin.text/replace-first) Replaces the first occurrence of the given regular expression [regex](../../kotlin.text/replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/regex) in this char sequence with specified [replacement](../../kotlin.text/replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement) expression. ``` fun CharSequence.replaceFirst(     regex: Regex,     replacement: String ): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceRange](../../kotlin.text/replace-range) Returns a char sequence with content of this char sequence where its part at the given range is replaced with the [replacement](../../kotlin.text/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 ``` Returns a char sequence with content of this char sequence where its part at the given [range](../../kotlin.text/replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) is replaced with the [replacement](../../kotlin.text/replace-range#kotlin.text%24replaceRange(kotlin.CharSequence,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/replacement) char sequence. ``` fun CharSequence.replaceRange(     range: IntRange,     replacement: CharSequence ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversed](../../kotlin.text/reversed) Returns a char sequence with characters in reversed order. ``` fun CharSequence.reversed(): CharSequence ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [runningFold](../../kotlin.text/running-fold) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/scan) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/slice) Returns a char sequence containing characters of the original char sequence at the specified range of [indices](../../kotlin.text/slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.ranges.IntRange)/indices). ``` fun CharSequence.slice(indices: IntRange): CharSequence ``` Returns a char sequence containing characters of the original char sequence at specified [indices](../../kotlin.text/slice#kotlin.text%24slice(kotlin.CharSequence,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun CharSequence.slice(indices: Iterable<Int>): CharSequence ``` #### [split](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/split-to-sequence) Splits this char sequence to a sequence of strings around occurrences of the specified [delimiters](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subSequence](../../kotlin.text/sub-sequence) Returns a subsequence of this char sequence specified by the given [range](../../kotlin.text/sub-sequence#kotlin.text%24subSequence(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) of indices. ``` fun CharSequence.subSequence(range: IntRange): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substring](../../kotlin.text/substring) Returns a substring of chars from a range of this char sequence starting at the [startIndex](../../kotlin.text/substring#kotlin.text%24substring(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the [endIndex](../../kotlin.text/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](../../kotlin.text/substring#kotlin.text%24substring(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) of this char sequence. ``` fun CharSequence.substring(range: IntRange): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sumBy](../../kotlin.text/sum-by) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/sum-by-double) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/sum-of) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/take) Returns a subsequence of this char sequence containing the first [n](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLast](../../kotlin.text/take-last) Returns a subsequence of this char sequence containing the last [n](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeLastWhile](../../kotlin.text/take-last-while) Returns a subsequence of this char sequence containing last characters that satisfy the given [predicate](../../kotlin.text/take-last-while#kotlin.text%24takeLastWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.takeLastWhile(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [takeWhile](../../kotlin.text/take-while) Returns a subsequence of this char sequence containing the first characters that satisfy the given [predicate](../../kotlin.text/take-while#kotlin.text%24takeWhile(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.takeWhile(     predicate: (Char) -> Boolean ): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toCollection](../../kotlin.text/to-collection) Appends all characters to the given [destination](../../kotlin.text/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) #### [toHashSet](../../kotlin.text/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) #### [toList](../../kotlin.text/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) #### [toMutableList](../../kotlin.text/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), JS (1.0), Native (1.0) #### [toSet](../../kotlin.text/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) #### [toSortedSet](../../kotlin.text/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.0), JS (1.0), Native (1.0) #### [trim](../../kotlin.text/trim) Returns a sub sequence of this char sequence having leading and trailing characters matching the [predicate](../../kotlin.text/trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trim(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having leading and trailing characters from the [chars](../../kotlin.text/trim#kotlin.text%24trim(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trim(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having leading and trailing whitespace removed. ``` fun CharSequence.trim(): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimEnd](../../kotlin.text/trim-end) Returns a sub sequence of this char sequence having trailing characters matching the [predicate](../../kotlin.text/trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trimEnd(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having trailing characters from the [chars](../../kotlin.text/trim-end#kotlin.text%24trimEnd(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trimEnd(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having trailing whitespace removed. ``` fun CharSequence.trimEnd(): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [trimStart](../../kotlin.text/trim-start) Returns a sub sequence of this char sequence having leading characters matching the [predicate](../../kotlin.text/trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun CharSequence.trimStart(     predicate: (Char) -> Boolean ): CharSequence ``` Returns a sub sequence of this char sequence having leading characters from the [chars](../../kotlin.text/trim-start#kotlin.text%24trimStart(kotlin.CharSequence,%20kotlin.CharArray)/chars) array removed. ``` fun CharSequence.trimStart(vararg chars: Char): CharSequence ``` Returns a sub sequence of this char sequence having leading whitespace removed. ``` fun CharSequence.trimStart(): CharSequence ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../../kotlin.text/windowed) Returns a list of snapshots of the window of the given [size](../../kotlin.text/windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/windowed-sequence) Returns a sequence of snapshots of the window of the given [size](../../kotlin.text/windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/zip) Returns a list of pairs built from the characters of `this` and the [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [String](../-string/index) The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. ``` class String : Comparable<String>, CharSequence ``` #### [StringBuilder](../../kotlin.text/-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 ```
programming_docs
kotlin length length ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharSequence](index) / <length> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract val length: Int ``` Returns the length of this character sequence. kotlin subSequence subSequence =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharSequence](index) / [subSequence](sub-sequence) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract fun subSequence(     startIndex: Int,     endIndex: Int ): CharSequence ``` Returns a new character sequence that is a subsequence of this character sequence, starting at the specified [startIndex](sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the specified [endIndex](sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/endIndex). Parameters ---------- `startIndex` - the start index (inclusive). `endIndex` - the end index (exclusive). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharSequence](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract operator fun get(index: Int): Char ``` ##### For Common, JVM, JS Returns the character at the specified [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) in this character sequence. Exceptions ---------- `IndexOutOfBoundsException` - if the [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) is out of bounds of this character sequence. Note that the [String](../-string/index#kotlin.String) implementation of this interface in Kotlin/JS has unspecified behavior if the [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) is out of its bounds. ##### For Native Returns the character at the specified [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) in this character sequence. Exceptions ---------- `IndexOutOfBoundsException` - if the [index](get#kotlin.CharSequence%24get(kotlin.Int)/index) is out of bounds of this character sequence. kotlin SubclassOptInRequired SubclassOptInRequired ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [SubclassOptInRequired](index) **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) ``` @Target([AnnotationTarget.CLASS]) annotation class SubclassOptInRequired ``` Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. When applied, any attempt to subclass the target declaration will trigger an opt-in with the corresponding level and message. The intended uses of subclass opt-in markers include, but are not limited to the following API: * Stable to use, but unstable to implement due to its further evolution. * Stable to use, but closed for 3rd-part implementations due to internal or technical reasons. * Stable to use, but delicate or fragile to implement. * Stable to use, but with a contract that may be weakened in the future in a backwards-incompatible manner for external implementations. Contrary to regular [RequiresOptIn](../-requires-opt-in/index), there are three ways to opt-in into the subclassing requirement: * Annotate declaration with the marker annotation, making it propagating. * Annotate declaration with [OptIn](../-opt-in/index) in order to opt in into the provided guarantees in a non-propagating manner. * Annotate declaration with [SubclassOptInRequired](index) with the same marker class, making it further propagating only for subclassing. Uses of this annotation are limited to open and abstract classes, and non-`fun` interfaces. Any other uses allowed by `CLASS` annotation target yield a compilation error. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. ``` SubclassOptInRequired(markerClass: KClass<out Annotation>) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [markerClass](marker-class) specifies marker annotation that require explicit opt-in. ``` val markerClass: KClass<out Annotation> ``` kotlin markerClass markerClass =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [SubclassOptInRequired](index) / [markerClass](marker-class) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val markerClass: KClass<out Annotation> ``` specifies marker annotation that require explicit opt-in. Property -------- `markerClass` - specifies marker annotation that require explicit opt-in. **See Also** [RequiresOptIn](../-requires-opt-in/index) kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [SubclassOptInRequired](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` SubclassOptInRequired(markerClass: KClass<out Annotation>) ``` Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. When applied, any attempt to subclass the target declaration will trigger an opt-in with the corresponding level and message. The intended uses of subclass opt-in markers include, but are not limited to the following API: * Stable to use, but unstable to implement due to its further evolution. * Stable to use, but closed for 3rd-part implementations due to internal or technical reasons. * Stable to use, but delicate or fragile to implement. * Stable to use, but with a contract that may be weakened in the future in a backwards-incompatible manner for external implementations. Contrary to regular [RequiresOptIn](../-requires-opt-in/index), there are three ways to opt-in into the subclassing requirement: * Annotate declaration with the marker annotation, making it propagating. * Annotate declaration with [OptIn](../-opt-in/index) in order to opt in into the provided guarantees in a non-propagating manner. * Annotate declaration with [SubclassOptInRequired](index) with the same marker class, making it further propagating only for subclassing. Uses of this annotation are limited to open and abstract classes, and non-`fun` interfaces. Any other uses allowed by `CLASS` annotation target yield a compilation error. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin DoubleArray DoubleArray =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class DoubleArray ``` An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Double) ``` Creates a new array of the specified [size](size#kotlin.DoubleArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.DoubleArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Double ``` **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(): DoubleIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/index) to the given [value](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Double) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val DoubleArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val DoubleArray.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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.all(predicate: (Double) -> 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 DoubleArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.any(predicate: (Double) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun DoubleArray.asIterable(): Iterable<Double> ``` **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 array returning its elements when being iterated. ``` fun DoubleArray.asSequence(): Sequence<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> DoubleArray.associate(     transform: (Double) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> DoubleArray.associateBy(     keySelector: (Double) -> K ): Map<K, Double> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> DoubleArray.associateBy(     keySelector: (Double) -> K,     valueTransform: (Double) -> 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.DoubleArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Double>> DoubleArray.associateByTo(     destination: M,     keySelector: (Double) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.DoubleArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.DoubleArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateByTo(     destination: M,     keySelector: (Double) -> K,     valueTransform: (Double) -> 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.DoubleArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> DoubleArray.associateTo(     destination: M,     transform: (Double) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> DoubleArray.associateWith(     valueSelector: (Double) -> V ): Map<Double, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.DoubleArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Double, in V>> DoubleArray.associateWithTo(     destination: M,     valueSelector: (Double) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun DoubleArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.DoubleArray,%20kotlin.Double,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun DoubleArray.binarySearch(     element: Double,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun DoubleArray.component1(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun DoubleArray.component2(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun DoubleArray.component3(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun DoubleArray.component4(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun DoubleArray.component5(): Double ``` **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.DoubleArray,%20kotlin.Double)/element) is found in the array. ``` operator fun DoubleArray.contains(element: Double): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun DoubleArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.count(predicate: (Double) -> 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 array. ``` fun DoubleArray.distinct(): List<Double> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> DoubleArray.distinctBy(     selector: (Double) -> K ): List<Double> ``` **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.DoubleArray,%20kotlin.Int)/n) elements. ``` fun DoubleArray.drop(n: Int): List<Double> ``` **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.DoubleArray,%20kotlin.Int)/n) elements. ``` fun DoubleArray.dropLast(n: Int): List<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.dropLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.dropWhile(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/index) is out of bounds of this array. ``` fun DoubleArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.DoubleArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.DoubleArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun DoubleArray.elementAtOrNull(index: Int): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.filter(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.filterIndexed(     predicate: (index: Int, Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.DoubleArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Double>> DoubleArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Double) -> Boolean ): 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.filterNot(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.DoubleArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Double>> DoubleArray.filterNotTo(     destination: C,     predicate: (Double) -> 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.DoubleArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.DoubleArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Double>> DoubleArray.filterTo(     destination: C,     predicate: (Double) -> 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun DoubleArray.find(predicate: (Double) -> Boolean): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun DoubleArray.findLast(     predicate: (Double) -> Boolean ): Double? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun DoubleArray.first(): Double ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.first(predicate: (Double) -> Boolean): Double ``` **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 DoubleArray.firstOrNull(): Double? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun DoubleArray.firstOrNull(     predicate: (Double) -> Boolean ): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> DoubleArray.flatMap(     transform: (Double) -> Iterable<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.DoubleArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> DoubleArray.flatMapIndexed(     transform: (index: Int, Double) -> Iterable<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.DoubleArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%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.DoubleArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> DoubleArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Double) -> Iterable<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.DoubleArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> DoubleArray.flatMapTo(     destination: C,     transform: (Double) -> Iterable<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.DoubleArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Double,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.DoubleArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Double,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> DoubleArray.fold(     initial: R,     operation: (acc: R, Double) -> 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.DoubleArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Double,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.DoubleArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Double,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> DoubleArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> 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.DoubleArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Double,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.DoubleArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Double,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> DoubleArray.foldRight(     initial: R,     operation: (Double, 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.DoubleArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.DoubleArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%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> DoubleArray.foldRightIndexed(     initial: R,     operation: (index: Int, Double, 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Unit)))/action) on each element. ``` fun DoubleArray.forEach(action: (Double) -> 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.DoubleArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun DoubleArray.forEachIndexed(     action: (index: Int, Double) -> 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.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.DoubleArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Double)))/index) is out of bounds of this array. ``` fun DoubleArray.getOrElse(     index: Int,     defaultValue: (Int) -> Double ): Double ``` **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.DoubleArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.DoubleArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun DoubleArray.getOrNull(index: Int): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%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> DoubleArray.groupBy(     keySelector: (Double) -> K ): Map<K, List<Double>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Double,%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> DoubleArray.groupBy(     keySelector: (Double) -> K,     valueTransform: (Double) -> 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.DoubleArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.DoubleArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Double>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.DoubleArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.DoubleArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Double,%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>>> DoubleArray.groupByTo(     destination: M,     keySelector: (Double) -> K,     valueTransform: (Double) -> V ): M ``` **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.DoubleArray,%20kotlin.Double)/element), or -1 if the array does not contain element. ``` fun DoubleArray.indexOf(element: Double): 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun DoubleArray.indexOfFirst(     predicate: (Double) -> 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun DoubleArray.indexOfLast(     predicate: (Double) -> 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 array and the specified collection. ``` infix fun DoubleArray.intersect(     other: Iterable<Double> ): Set<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun DoubleArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun DoubleArray.isNotEmpty(): 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.DoubleArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.DoubleArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.DoubleArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> DoubleArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> 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.DoubleArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.DoubleArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.DoubleArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Double,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun DoubleArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Double) -> 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 DoubleArray.last(): Double ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.last(predicate: (Double) -> Boolean): Double ``` **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.DoubleArray,%20kotlin.Double)/element), or -1 if the array does not contain element. ``` fun DoubleArray.lastIndexOf(element: Double): 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 DoubleArray.lastOrNull(): Double? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun DoubleArray.lastOrNull(     predicate: (Double) -> Boolean ): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> DoubleArray.map(transform: (Double) -> 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.DoubleArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> DoubleArray.mapIndexed(     transform: (index: Int, Double) -> R ): List<R> ``` **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.DoubleArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%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.DoubleArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> DoubleArray.mapIndexedTo(     destination: C,     transform: (index: Int, Double) -> 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.DoubleArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Double,%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.DoubleArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> DoubleArray.mapTo(     destination: C,     transform: (Double) -> 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>> DoubleArray.maxByOrNull(     selector: (Double) -> R ): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Double) -> 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Double) -> 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.DoubleArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.DoubleArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> DoubleArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Double) -> 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.DoubleArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.DoubleArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> DoubleArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> 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 DoubleArray.maxOrNull(): Double? ``` #### [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.DoubleArray,%20kotlin.Comparator((kotlin.Double)))/comparator). ``` fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun DoubleArray.maxWith(     comparator: Comparator<in Double> ): Double? ``` **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.DoubleArray,%20kotlin.Comparator((kotlin.Double)))/comparator) or `null` if there are no elements. ``` fun DoubleArray.maxWithOrNull(     comparator: Comparator<in Double> ): Double? ``` **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>> DoubleArray.minByOrNull(     selector: (Double) -> R ): Double? ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Double) -> 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Double) -> 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.DoubleArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.DoubleArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> DoubleArray.minOfWith(     comparator: Comparator<in R>,     selector: (Double) -> 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.DoubleArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.DoubleArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Double,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> DoubleArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Double) -> 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 DoubleArray.minOrNull(): Double? ``` #### [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.DoubleArray,%20kotlin.Comparator((kotlin.Double)))/comparator). ``` fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double ``` **Platform and version requirements:** JVM (1.0) ``` fun DoubleArray.minWith(     comparator: Comparator<in Double> ): Double? ``` **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.DoubleArray,%20kotlin.Comparator((kotlin.Double)))/comparator) or `null` if there are no elements. ``` fun DoubleArray.minWithOrNull(     comparator: Comparator<in Double> ): Double? ``` **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 DoubleArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.none(predicate: (Double) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun DoubleArray.onEach(action: (Double) -> Unit): DoubleArray ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Double,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun DoubleArray.onEachIndexed(     action: (index: Int, Double) -> Unit ): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun DoubleArray.partition(     predicate: (Double) -> Boolean ): Pair<List<Double>, List<Double>> ``` **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 DoubleArray.random(): Double ``` Returns a random element from this array using the specified source of randomness. ``` fun DoubleArray.random(random: Random): Double ``` **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 DoubleArray.randomOrNull(): Double? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun DoubleArray.randomOrNull(random: Random): Double? ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun DoubleArray.reduce(     operation: (acc: Double, Double) -> Double ): Double ``` **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.DoubleArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun DoubleArray.reduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): Double ``` **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.DoubleArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun DoubleArray.reduceIndexedOrNull(     operation: (index: Int, acc: Double, Double) -> Double ): Double? ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun DoubleArray.reduceOrNull(     operation: (acc: Double, Double) -> Double ): Double? ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun DoubleArray.reduceRight(     operation: (Double, acc: Double) -> Double ): Double ``` **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.DoubleArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun DoubleArray.reduceRightIndexed(     operation: (index: Int, Double, acc: Double) -> Double ): Double ``` **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.DoubleArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun DoubleArray.reduceRightIndexedOrNull(     operation: (index: Int, Double, acc: Double) -> Double ): Double? ``` **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.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun DoubleArray.reduceRightOrNull(     operation: (Double, acc: Double) -> Double ): Double? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun DoubleArray.refTo(index: Int): CValuesRef<DoubleVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun DoubleArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun DoubleArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 DoubleArray.reversed(): List<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun DoubleArray.reversedArray(): DoubleArray ``` **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.DoubleArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Double,%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.DoubleArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Double,%20)))/initial) value. ``` fun <R> DoubleArray.runningFold(     initial: R,     operation: (acc: R, Double) -> 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.DoubleArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Double,%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.DoubleArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Double,%20)))/initial) value. ``` fun <R> DoubleArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> 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.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun DoubleArray.runningReduce(     operation: (acc: Double, Double) -> Double ): List<Double> ``` **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.DoubleArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Double,%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 DoubleArray.runningReduceIndexed(     operation: (index: Int, acc: Double, Double) -> Double ): List<Double> ``` **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.DoubleArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Double,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.DoubleArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Double,%20)))/initial) value. ``` fun <R> DoubleArray.scan(     initial: R,     operation: (acc: R, Double) -> 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.DoubleArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Double,%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.DoubleArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Double,%20)))/initial) value. ``` fun <R> DoubleArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Double) -> 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 DoubleArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.DoubleArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun DoubleArray.shuffle(random: Random) ``` **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 DoubleArray.single(): Double ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun DoubleArray.single(     predicate: (Double) -> Boolean ): Double ``` **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 DoubleArray.singleOrNull(): Double? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun DoubleArray.singleOrNull(     predicate: (Double) -> Boolean ): Double? ``` **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.DoubleArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun DoubleArray.slice(indices: IntRange): List<Double> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.DoubleArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun DoubleArray.slice(indices: Iterable<Int>): List<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.DoubleArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun DoubleArray.sliceArray(     indices: Collection<Int> ): DoubleArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.DoubleArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun DoubleArray.sliceArray(indices: IntRange): DoubleArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20kotlin.Int)))/comparison) function. ``` fun DoubleArray.sort(     comparison: (a: Double, b: Double) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun DoubleArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun DoubleArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun DoubleArray.sorted(): List<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun DoubleArray.sortedArray(): DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun DoubleArray.sortedArrayDescending(): DoubleArray ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> DoubleArray.sortedBy(     selector: (Double) -> R? ): List<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> DoubleArray.sortedByDescending(     selector: (Double) -> R? ): List<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun DoubleArray.sortedDescending(): List<Double> ``` **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.DoubleArray,%20kotlin.Comparator((kotlin.Double)))/comparator). ``` fun DoubleArray.sortedWith(     comparator: Comparator<in Double> ): List<Double> ``` **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 array and not contained by the specified collection. ``` infix fun DoubleArray.subtract(     other: Iterable<Double> ): Set<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun DoubleArray.sum(): Double ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun DoubleArray.sumBy(selector: (Double) -> 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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array. ``` fun DoubleArray.sumByDouble(     selector: (Double) -> Double ): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.DoubleArray,%20kotlin.Function1((kotlin.Double,%20)))/selector) function applied to each element in the array. **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 DoubleArray.sumOf(selector: (Double) -> Int): Int ``` **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.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 DoubleArray.sumOf(selector: (Double) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun DoubleArray.sumOf(     selector: (Double) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun DoubleArray.sumOf(     selector: (Double) -> BigInteger ): BigInteger ``` **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.DoubleArray,%20kotlin.Int)/n) elements. ``` fun DoubleArray.take(n: Int): List<Double> ``` **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.DoubleArray,%20kotlin.Int)/n) elements. ``` fun DoubleArray.takeLast(n: Int): List<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.takeLastWhile(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.Function1((kotlin.Double,%20kotlin.Boolean)))/predicate). ``` fun DoubleArray.takeWhile(     predicate: (Double) -> Boolean ): List<Double> ``` **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.DoubleArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Double>> DoubleArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun DoubleArray.toCValues(): CValues<DoubleVar> ``` **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 DoubleArray.toHashSet(): HashSet<Double> ``` **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 DoubleArray.toList(): List<Double> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun DoubleArray.toMutableList(): MutableList<Double> ``` **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 array. ``` fun DoubleArray.toMutableSet(): MutableSet<Double> ``` **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 DoubleArray.toSet(): Set<Double> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun DoubleArray.toSortedSet(): SortedSet<Double> ``` **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 DoubleArray.union(     other: Iterable<Double> ): Set<Double> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun DoubleArray.withIndex(): Iterable<IndexedValue<Double>> ``` **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.DoubleArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Double, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.DoubleArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Double,%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.DoubleArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Double,%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> DoubleArray.zip(     other: Array<out R>,     transform: (a: Double, 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.DoubleArray,%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> DoubleArray.zip(     other: Iterable<R> ): List<Pair<Double, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.DoubleArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Double,%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.DoubleArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Double,%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> DoubleArray.zip(     other: Iterable<R>,     transform: (a: Double, 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.DoubleArray,%20kotlin.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.DoubleArray,%20kotlin.DoubleArray,%20kotlin.Function2((kotlin.Double,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> DoubleArray.zip(     other: DoubleArray,     transform: (a: Double, b: Double) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): DoubleIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Double) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.DoubleArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.DoubleArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Double) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/index) to the given [value](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/value). This method can be called using the index operator. If the [index](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/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. ##### For Native Sets the element at the given [index](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/index) to the given [value](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/value). This method can be called using the index operator. If the [index](set#kotlin.DoubleArray%24set(kotlin.Int,%20kotlin.Double)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DoubleArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Double ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.DoubleArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.DoubleArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.DoubleArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.DoubleArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin Boolean Boolean ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Boolean : Comparable<Boolean> ``` Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are represented as values of the primitive type `boolean`. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <and> Performs a logical `and` operation between this Boolean and the [other](and#kotlin.Boolean%24and(kotlin.Boolean)/other) one. Unlike the `&&` operator, this function does not perform short-circuit evaluation. Both `this` and [other](and#kotlin.Boolean%24and(kotlin.Boolean)/other) will always be evaluated. ``` infix fun and(other: Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). ``` fun compareTo(other: Boolean): Int ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Boolean): 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) #### <not> Returns the inverse of this boolean. ``` operator fun not(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <or> Performs a logical `or` operation between this Boolean and the [other](or#kotlin.Boolean%24or(kotlin.Boolean)/other) one. Unlike the `||` operator, this function does not perform short-circuit evaluation. Both `this` and [other](or#kotlin.Boolean%24or(kotlin.Boolean)/other) will always be evaluated. ``` infix fun or(other: Boolean): Boolean ``` **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) #### <xor> Performs a logical `xor` operation between this Boolean and the [other](xor#kotlin.Boolean%24xor(kotlin.Boolean)/other) one. ``` infix fun xor(other: Boolean): Boolean ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** 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) #### [toByte](../../kotlinx.cinterop/to-byte) ``` fun Boolean.toByte(): Byte ``` kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun compareTo(other: Boolean): Int ``` Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](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) / [Boolean](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun and(other: Boolean): Boolean ``` Performs a logical `and` operation between this Boolean and the [other](and#kotlin.Boolean%24and(kotlin.Boolean)/other) one. Unlike the `&&` operator, this function does not perform short-circuit evaluation. Both `this` and [other](and#kotlin.Boolean%24and(kotlin.Boolean)/other) will always be evaluated. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](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 xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun xor(other: Boolean): Boolean ``` Performs a logical `xor` operation between this Boolean and the [other](xor#kotlin.Boolean%24xor(kotlin.Boolean)/other) one. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](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: Boolean): Boolean ``` kotlin not not === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](index) / <not> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun not(): Boolean ``` Returns the inverse of this boolean. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Boolean](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun or(other: Boolean): Boolean ``` Performs a logical `or` operation between this Boolean and the [other](or#kotlin.Boolean%24or(kotlin.Boolean)/other) one. Unlike the `||` operator, this function does not perform short-circuit evaluation. Both `this` and [other](or#kotlin.Boolean%24or(kotlin.Boolean)/other) will always be evaluated. kotlin UninitializedPropertyAccessException UninitializedPropertyAccessException ==================================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UninitializedPropertyAccessException](index) **Platform and version requirements:** ``` class UninitializedPropertyAccessException : RuntimeException ``` **Deprecated:** This exception type is not supposed to be thrown or caught in common code and will be removed from kotlin-stdlib-common soon. **Platform and version requirements:** JVM (1.0) ``` class UninitializedPropertyAccessException : RuntimeException ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class UninitializedPropertyAccessException :      RuntimeException ``` Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` 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) / [UninitializedPropertyAccessException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` kotlin Enum Enum ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract class Enum<E : Enum<E>> : Comparable<E> ``` The common base class of all enum classes. See the [Kotlin language documentation](../../../../../../docs/enum-classes) for more information on enum classes. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) The common base class of all enum classes. See the [Kotlin language documentation](../../../../../../docs/enum-classes) for more information on enum classes. ``` <init>(name: String, ordinal: Int) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <name> Returns the name of this enum constant, exactly as declared in its enum declaration. ``` val name: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <ordinal> Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). ``` val ordinal: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <clone> Throws an exception since enum constants cannot be cloned. This method prevents enum classes from inheriting from `Cloneable`. ``` fun clone(): Any ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). ``` fun compareTo(other: E): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [toString](to-string) Returns a string representation of the object. ``` open fun toString(): String ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.7) #### [declaringJavaClass](../../kotlin.jvm/declaring-java-class) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance of the enum the given constant belongs to. ``` val <E : Enum<E>> Enum<E>.declaringJavaClass: Class<E> ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** 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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AnnotationRetention](../../kotlin.annotation/-annotation-retention/index) Contains the list of possible annotation's retentions. ``` enum class AnnotationRetention ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AnnotationTarget](../../kotlin.annotation/-annotation-target/index) Contains the list of code elements which are the possible annotation targets ``` enum class AnnotationTarget ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [CharCategory](../../kotlin.text/-char-category/index) Represents the character general category in the Unicode specification. ``` enum class CharCategory ``` **Platform and version requirements:** JVM (1.0) #### [CharDirectionality](../../kotlin.text/-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), JRE7 (1.0) #### [CopyActionResult](../../kotlin.io.path/-copy-action-result/index) The result of the `copyAction` function passed to [Path.copyToRecursively](../../kotlin.io.path/java.nio.file.-path/copy-to-recursively) that specifies further actions when copying an entry. ``` enum class CopyActionResult ``` **Platform and version requirements:** Native (1.3) #### [CpuArchitecture](../../kotlin.native/-cpu-architecture/index) Central Processor Unit architecture. ``` enum class CpuArchitecture ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DeprecationLevel](../-deprecation-level/index) Possible levels of a deprecation. The level specifies how the deprecated element usages are reported in code. ``` enum class DeprecationLevel ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [DurationUnit](../../kotlin.time/-duration-unit/index) The list of possible time measurement units, in which a duration can be expressed. ``` enum class DurationUnit ``` **Platform and version requirements:** JVM (1.0) #### [FileWalkDirection](../../kotlin.io/-file-walk-direction/index) An enumeration to describe possible walk directions. There are two of them: beginning from parents, ending with children, and beginning from children, ending with parents. Both use depth-first search. ``` enum class FileWalkDirection ``` **Platform and version requirements:** Native (1.3) #### [FutureState](../../kotlin.native.concurrent/-future-state/index) State of the future object. ``` enum class FutureState ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [InvocationKind](../../kotlin.contracts/-invocation-kind/index) Specifies how many times a function invokes its function parameter in place. ``` enum class InvocationKind ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KVariance](../../kotlin.reflect/-k-variance/index) Represents variance applied to a type parameter on the declaration site (*declaration-site variance*), or to a type in a projection (*use-site variance*). ``` enum class KVariance ``` **Platform and version requirements:** JVM (1.1) #### [KVisibility](../../kotlin.reflect/-k-visibility/index) Visibility is an aspect of a Kotlin declaration regulating where that declaration is accessible in the source code. Visibility can be changed with one of the following modifiers: `public`, `protected`, `internal`, `private`. ``` enum class KVisibility ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LazyThreadSafetyMode](../-lazy-thread-safety-mode/index) Specifies how a [Lazy](../-lazy/index) instance synchronizes initialization among multiple threads. ``` enum class LazyThreadSafetyMode ``` **Platform and version requirements:** Native (1.3) #### [MemoryModel](../../kotlin.native/-memory-model/index) Memory model. ``` enum class MemoryModel ``` **Platform and version requirements:** JVM (1.0) #### [OnErrorAction](../../kotlin.io/-on-error-action/index) Enum that can be used to specify behaviour of the `copyRecursively()` function in exceptional conditions. ``` enum class OnErrorAction ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [OnErrorResult](../../kotlin.io.path/-on-error-result/index) The result of the `onError` function passed to [Path.copyToRecursively](../../kotlin.io.path/java.nio.file.-path/copy-to-recursively) that specifies further actions when an exception occurs. ``` enum class OnErrorResult ``` **Platform and version requirements:** Native (1.3) #### [OsFamily](../../kotlin.native/-os-family/index) Operating system family. ``` enum class OsFamily ``` **Platform and version requirements:** JVM (1.0), JRE7 (1.0) #### [PathWalkOption](../../kotlin.io.path/-path-walk-option/index) An enumeration to provide walk options for [Path.walk](../../kotlin.io.path/java.nio.file.-path/walk) function. The options can be combined to form the walk order and behavior needed. ``` enum class PathWalkOption ``` #### [RegexOption](../../kotlin.text/-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 ``` **Platform and version requirements:** Native (1.3) #### [TransferMode](../../kotlin.native.concurrent/-transfer-mode/index) Note: modern Kotlin/Native memory manager allows to share objects between threads without additional ceremonies, so TransferMode has effect only in legacy memory manager. ``` enum class TransferMode ```
programming_docs
kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun compareTo(other: E): Int ``` Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.1), 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 toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` open fun toString(): String ``` Returns a string representation of the object. kotlin clone clone ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / <clone> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.0) ``` protected fun clone(): Any ``` Throws an exception since enum constants cannot be cloned. This method prevents enum classes from inheriting from `Cloneable`. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` <init>(name: String, ordinal: Int) ``` The common base class of all enum classes. See the [Kotlin language documentation](../../../../../../docs/enum-classes) for more information on enum classes. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` 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. kotlin name name ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / <name> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` val name: String ``` Returns the name of this enum constant, exactly as declared in its enum declaration. kotlin ordinal ordinal ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Enum](index) / <ordinal> **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` val ordinal: Int ``` Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant is assigned an ordinal of zero). kotlin ExperimentalUnsignedTypes ExperimentalUnsignedTypes ========================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalUnsignedTypes](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 ExperimentalUnsignedTypes ``` Marks the API that is dependent on the experimental unsigned types, including those types themselves. Usages of such API will be reported as warnings unless an explicit opt-in with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalUnsignedTypes::class)`, or with the `-opt-in=kotlin.ExperimentalUnsignedTypes` compiler option is given. It's recommended to propagate the experimental status to the API that depends on unsigned types by annotating it with this annotation. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Marks the API that is dependent on the experimental unsigned types, including those types themselves. ``` ExperimentalUnsignedTypes() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalUnsignedTypes](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ExperimentalUnsignedTypes() ``` Marks the API that is dependent on the experimental unsigned types, including those types themselves. Usages of such API will be reported as warnings unless an explicit opt-in with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalUnsignedTypes::class)`, or with the `-opt-in=kotlin.ExperimentalUnsignedTypes` compiler option is given. It's recommended to propagate the experimental status to the API that depends on unsigned types by annotating it with this annotation. kotlin ArrayIndexOutOfBoundsException ArrayIndexOutOfBoundsException ============================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ArrayIndexOutOfBoundsException](index) **Platform and version requirements:** Native (1.3) ``` open class ArrayIndexOutOfBoundsException :      IndexOutOfBoundsException ``` Constructors ------------ **Platform and version requirements:** Native (1.3) #### [<init>](-init-) ``` ArrayIndexOutOfBoundsException() ``` ``` ArrayIndexOutOfBoundsException(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) / [ArrayIndexOutOfBoundsException](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` ArrayIndexOutOfBoundsException() ``` ``` ArrayIndexOutOfBoundsException(message: String?) ``` kotlin NoWhenBranchMatchedException NoWhenBranchMatchedException ============================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NoWhenBranchMatchedException](index) **Platform and version requirements:** ``` open class NoWhenBranchMatchedException : RuntimeException ``` **Deprecated:** This exception type is not supposed to be thrown or caught in common code and will be removed from kotlin-stdlib-common soon. **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` open class NoWhenBranchMatchedException : RuntimeException ``` Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` 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) / [NoWhenBranchMatchedException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` ``` <init>(message: String?, cause: Throwable?) ``` ``` <init>(cause: Throwable?) ``` kotlin SinceKotlin SinceKotlin =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [SinceKotlin](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPEALIAS]) annotation class SinceKotlin ``` Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. ``` <init>(version: String) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <version> the version in the following formats: `<major>.<minor>` or `<major>.<minor>.<patch>`, where major, minor and patch are non-negative integer numbers without leading zeros. ``` val version: String ``` 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) / [SinceKotlin](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(version: String) ``` Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. kotlin version version ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [SinceKotlin](index) / <version> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val version: String ``` the version in the following formats: `<major>.<minor>` or `<major>.<minor>.<patch>`, where major, minor and patch are non-negative integer numbers without leading zeros. Property -------- `version` - the version in the following formats: `<major>.<minor>` or `<major>.<minor>.<patch>`, where major, minor and patch are non-negative integer numbers without leading zeros. kotlin ClassCastException ClassCastException ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ClassCastException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ClassCastException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias ClassCastException = ClassCastException ``` 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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), Native (1.0) #### [TypeCastException](../-type-cast-exception/index) ``` open class TypeCastException : ClassCastException ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ClassCastException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin Exception Exception ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [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 ``` 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 ---------- #### [CharacterCodingException](../../kotlin.text/-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 ``` **Platform and version requirements:** Native (1.3) #### [ForeignException](../../kotlinx.cinterop/-foreign-exception/index) ``` class ForeignException : Exception ``` **Platform and version requirements:** JVM (1.1) #### [IllegalCallableAccessException](../../kotlin.reflect.full/-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](../../kotlin.reflect.full/-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](../../kotlin.reflect.full/-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 ``` #### [RuntimeException](../-runtime-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class RuntimeException : Exception ``` **Platform and version requirements:** JVM (1.1) ``` typealias RuntimeException = RuntimeException ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Exception](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 RuntimeException RuntimeException ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RuntimeException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class RuntimeException : Exception ``` **Platform and version requirements:** JVM (1.1) ``` typealias RuntimeException = RuntimeException ``` 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> ``` Inheritors ---------- #### [ArithmeticException](../-arithmetic-exception/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 ``` #### [ClassCastException](../-class-cast-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ClassCastException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias ClassCastException = ClassCastException ``` #### [ConcurrentModificationException](../-concurrent-modification-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ConcurrentModificationException : RuntimeException ``` **Platform and version requirements:** JVM (1.3) ``` typealias ConcurrentModificationException = ConcurrentModificationException ``` **Platform and version requirements:** Native (1.3) #### [FileFailedToInitializeException](../../kotlin.native/-file-failed-to-initialize-exception/index) Exception thrown when there was an error during file initalization. ``` class FileFailedToInitializeException : RuntimeException ``` **Platform and version requirements:** Native (1.3) #### [FreezingException](../../kotlin.native.concurrent/-freezing-exception/index) Exception thrown whenever freezing is not possible. ``` class FreezingException : RuntimeException ``` #### [IllegalArgumentException](../-illegal-argument-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalArgumentException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalArgumentException = IllegalArgumentException ``` #### [IllegalStateException](../-illegal-state-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalStateException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalStateException = IllegalStateException ``` **Platform and version requirements:** Native (1.3) #### [IncorrectDereferenceException](../../kotlin.native/-incorrect-dereference-exception/index) Exception thrown when top level variable is accessed from incorrect execution context. ``` class IncorrectDereferenceException : RuntimeException ``` #### [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IndexOutOfBoundsException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IndexOutOfBoundsException = IndexOutOfBoundsException ``` **Platform and version requirements:** Native (1.3) #### [InvalidMutabilityException](../../kotlin.native.concurrent/-invalid-mutability-exception/index) Exception thrown whenever we attempt to mutate frozen objects. ``` class InvalidMutabilityException : RuntimeException ``` #### [NoSuchElementException](../-no-such-element-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NoSuchElementException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NoSuchElementException = NoSuchElementException ``` #### [NoWhenBranchMatchedException](../-no-when-branch-matched-exception/index) **Platform and version requirements:** ``` open class NoWhenBranchMatchedException : RuntimeException ``` **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` open class NoWhenBranchMatchedException : RuntimeException ``` #### [NullPointerException](../-null-pointer-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NullPointerException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NullPointerException = NullPointerException ``` #### [UninitializedPropertyAccessException](../-uninitialized-property-access-exception/index) **Platform and version requirements:** ``` class UninitializedPropertyAccessException : RuntimeException ``` **Platform and version requirements:** JVM (1.0) ``` class UninitializedPropertyAccessException : RuntimeException ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class UninitializedPropertyAccessException :      RuntimeException ``` #### [UnsupportedOperationException](../-unsupported-operation-exception/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 ```
programming_docs
kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [RuntimeException](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 size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin FloatArray FloatArray ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class FloatArray ``` ##### For Common, JVM, JS An array of floats. When targeting the JVM, instances of this class are represented as `float[]`. ##### For Native An array of floats. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Float) ``` Creates a new array of the specified [size](size#kotlin.FloatArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.FloatArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Float ``` **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(): FloatIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/index) to the given [value](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Float) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val FloatArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val FloatArray.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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.all(predicate: (Float) -> 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 FloatArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.any(predicate: (Float) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun FloatArray.asIterable(): Iterable<Float> ``` **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 array returning its elements when being iterated. ``` fun FloatArray.asSequence(): Sequence<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> FloatArray.associate(     transform: (Float) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> FloatArray.associateBy(     keySelector: (Float) -> K ): Map<K, Float> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> FloatArray.associateBy(     keySelector: (Float) -> K,     valueTransform: (Float) -> 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.FloatArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Float>> FloatArray.associateByTo(     destination: M,     keySelector: (Float) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.FloatArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.FloatArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateByTo(     destination: M,     keySelector: (Float) -> K,     valueTransform: (Float) -> 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.FloatArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> FloatArray.associateTo(     destination: M,     transform: (Float) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> FloatArray.associateWith(     valueSelector: (Float) -> V ): Map<Float, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.FloatArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Float, in V>> FloatArray.associateWithTo(     destination: M,     valueSelector: (Float) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun FloatArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.FloatArray,%20kotlin.Float,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun FloatArray.binarySearch(     element: Float,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun FloatArray.component1(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun FloatArray.component2(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun FloatArray.component3(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun FloatArray.component4(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun FloatArray.component5(): Float ``` **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.FloatArray,%20kotlin.Float)/element) is found in the array. ``` operator fun FloatArray.contains(element: Float): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun FloatArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.count(predicate: (Float) -> 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 array. ``` fun FloatArray.distinct(): List<Float> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> FloatArray.distinctBy(     selector: (Float) -> K ): List<Float> ``` **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.FloatArray,%20kotlin.Int)/n) elements. ``` fun FloatArray.drop(n: Int): List<Float> ``` **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.FloatArray,%20kotlin.Int)/n) elements. ``` fun FloatArray.dropLast(n: Int): List<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.dropLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.dropWhile(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/index) is out of bounds of this array. ``` fun FloatArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.FloatArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.FloatArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun FloatArray.elementAtOrNull(index: Int): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.filter(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.filterIndexed(     predicate: (index: Int, Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.FloatArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Float>> FloatArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Float) -> Boolean ): 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.filterNot(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.FloatArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Float>> FloatArray.filterNotTo(     destination: C,     predicate: (Float) -> 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.FloatArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.FloatArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Float>> FloatArray.filterTo(     destination: C,     predicate: (Float) -> 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun FloatArray.find(predicate: (Float) -> Boolean): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun FloatArray.findLast(     predicate: (Float) -> Boolean ): Float? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun FloatArray.first(): Float ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.first(predicate: (Float) -> Boolean): Float ``` **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 FloatArray.firstOrNull(): Float? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun FloatArray.firstOrNull(     predicate: (Float) -> Boolean ): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> FloatArray.flatMap(     transform: (Float) -> Iterable<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.FloatArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> FloatArray.flatMapIndexed(     transform: (index: Int, Float) -> Iterable<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.FloatArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%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.FloatArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> FloatArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Float) -> Iterable<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.FloatArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> FloatArray.flatMapTo(     destination: C,     transform: (Float) -> Iterable<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.FloatArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Float,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.FloatArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Float,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> FloatArray.fold(     initial: R,     operation: (acc: R, Float) -> 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.FloatArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Float,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.FloatArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Float,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> FloatArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> 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.FloatArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Float,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.FloatArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Float,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> FloatArray.foldRight(     initial: R,     operation: (Float, 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.FloatArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.FloatArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%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> FloatArray.foldRightIndexed(     initial: R,     operation: (index: Int, Float, 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Unit)))/action) on each element. ``` fun FloatArray.forEach(action: (Float) -> 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.FloatArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun FloatArray.forEachIndexed(     action: (index: Int, Float) -> 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.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.FloatArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Float)))/index) is out of bounds of this array. ``` fun FloatArray.getOrElse(     index: Int,     defaultValue: (Int) -> Float ): Float ``` **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.FloatArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.FloatArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun FloatArray.getOrNull(index: Int): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%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> FloatArray.groupBy(     keySelector: (Float) -> K ): Map<K, List<Float>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Float,%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> FloatArray.groupBy(     keySelector: (Float) -> K,     valueTransform: (Float) -> 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.FloatArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.FloatArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Float>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.FloatArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.FloatArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Float,%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>>> FloatArray.groupByTo(     destination: M,     keySelector: (Float) -> K,     valueTransform: (Float) -> V ): M ``` **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.FloatArray,%20kotlin.Float)/element), or -1 if the array does not contain element. ``` fun FloatArray.indexOf(element: Float): 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun FloatArray.indexOfFirst(     predicate: (Float) -> 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun FloatArray.indexOfLast(     predicate: (Float) -> 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 array and the specified collection. ``` infix fun FloatArray.intersect(     other: Iterable<Float> ): Set<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun FloatArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun FloatArray.isNotEmpty(): 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.FloatArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.FloatArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.FloatArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> FloatArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> 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.FloatArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.FloatArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.FloatArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Float,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun FloatArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Float) -> 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 FloatArray.last(): Float ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.last(predicate: (Float) -> Boolean): Float ``` **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.FloatArray,%20kotlin.Float)/element), or -1 if the array does not contain element. ``` fun FloatArray.lastIndexOf(element: Float): 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 FloatArray.lastOrNull(): Float? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun FloatArray.lastOrNull(     predicate: (Float) -> Boolean ): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> FloatArray.map(transform: (Float) -> 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.FloatArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> FloatArray.mapIndexed(     transform: (index: Int, Float) -> R ): List<R> ``` **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.FloatArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%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.FloatArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> FloatArray.mapIndexedTo(     destination: C,     transform: (index: Int, Float) -> 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.FloatArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Float,%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.FloatArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> FloatArray.mapTo(     destination: C,     transform: (Float) -> 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>> FloatArray.maxByOrNull(     selector: (Float) -> R ): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Float) -> 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Float) -> 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.FloatArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.FloatArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> FloatArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Float) -> 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.FloatArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.FloatArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> FloatArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> 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 FloatArray.maxOrNull(): Float? ``` #### [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.FloatArray,%20kotlin.Comparator((kotlin.Float)))/comparator). ``` fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun FloatArray.maxWith(     comparator: Comparator<in Float> ): Float? ``` **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.FloatArray,%20kotlin.Comparator((kotlin.Float)))/comparator) or `null` if there are no elements. ``` fun FloatArray.maxWithOrNull(     comparator: Comparator<in Float> ): Float? ``` **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>> FloatArray.minByOrNull(     selector: (Float) -> R ): Float? ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Float) -> 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Float) -> 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.FloatArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.FloatArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> FloatArray.minOfWith(     comparator: Comparator<in R>,     selector: (Float) -> 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.FloatArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.FloatArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Float,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> FloatArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Float) -> 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 FloatArray.minOrNull(): Float? ``` #### [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.FloatArray,%20kotlin.Comparator((kotlin.Float)))/comparator). ``` fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float ``` **Platform and version requirements:** JVM (1.0) ``` fun FloatArray.minWith(     comparator: Comparator<in Float> ): Float? ``` **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.FloatArray,%20kotlin.Comparator((kotlin.Float)))/comparator) or `null` if there are no elements. ``` fun FloatArray.minWithOrNull(     comparator: Comparator<in Float> ): Float? ``` **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 FloatArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.none(predicate: (Float) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun FloatArray.onEach(action: (Float) -> Unit): FloatArray ``` **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.FloatArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Float,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun FloatArray.onEachIndexed(     action: (index: Int, Float) -> Unit ): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun FloatArray.partition(     predicate: (Float) -> Boolean ): Pair<List<Float>, List<Float>> ``` **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 FloatArray.random(): Float ``` Returns a random element from this array using the specified source of randomness. ``` fun FloatArray.random(random: Random): Float ``` **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 FloatArray.randomOrNull(): Float? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun FloatArray.randomOrNull(random: Random): Float? ``` **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.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun FloatArray.reduce(     operation: (acc: Float, Float) -> Float ): Float ``` **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.FloatArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun FloatArray.reduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): Float ``` **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.FloatArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun FloatArray.reduceIndexedOrNull(     operation: (index: Int, acc: Float, Float) -> Float ): Float? ``` **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.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun FloatArray.reduceOrNull(     operation: (acc: Float, Float) -> Float ): Float? ``` **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.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun FloatArray.reduceRight(     operation: (Float, acc: Float) -> Float ): Float ``` **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.FloatArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun FloatArray.reduceRightIndexed(     operation: (index: Int, Float, acc: Float) -> Float ): Float ``` **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.FloatArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun FloatArray.reduceRightIndexedOrNull(     operation: (index: Int, Float, acc: Float) -> Float ): Float? ``` **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.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun FloatArray.reduceRightOrNull(     operation: (Float, acc: Float) -> Float ): Float? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun FloatArray.refTo(index: Int): CValuesRef<FloatVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun FloatArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun FloatArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 FloatArray.reversed(): List<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun FloatArray.reversedArray(): FloatArray ``` **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.FloatArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Float,%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.FloatArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Float,%20)))/initial) value. ``` fun <R> FloatArray.runningFold(     initial: R,     operation: (acc: R, Float) -> 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.FloatArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Float,%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.FloatArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Float,%20)))/initial) value. ``` fun <R> FloatArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> 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.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun FloatArray.runningReduce(     operation: (acc: Float, Float) -> Float ): List<Float> ``` **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.FloatArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Float,%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 FloatArray.runningReduceIndexed(     operation: (index: Int, acc: Float, Float) -> Float ): List<Float> ``` **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.FloatArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Float,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.FloatArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Float,%20)))/initial) value. ``` fun <R> FloatArray.scan(     initial: R,     operation: (acc: R, Float) -> 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.FloatArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Float,%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.FloatArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Float,%20)))/initial) value. ``` fun <R> FloatArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Float) -> 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 FloatArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.FloatArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun FloatArray.shuffle(random: Random) ``` **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 FloatArray.single(): Float ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun FloatArray.single(predicate: (Float) -> Boolean): Float ``` **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 FloatArray.singleOrNull(): Float? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun FloatArray.singleOrNull(     predicate: (Float) -> Boolean ): Float? ``` **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.FloatArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun FloatArray.slice(indices: IntRange): List<Float> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.FloatArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun FloatArray.slice(indices: Iterable<Int>): List<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.FloatArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun FloatArray.sliceArray(     indices: Collection<Int> ): FloatArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.FloatArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun FloatArray.sliceArray(indices: IntRange): FloatArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20kotlin.Int)))/comparison) function. ``` fun FloatArray.sort(comparison: (a: Float, b: Float) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun FloatArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun FloatArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun FloatArray.sorted(): List<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun FloatArray.sortedArray(): FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun FloatArray.sortedArrayDescending(): FloatArray ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> FloatArray.sortedBy(     selector: (Float) -> R? ): List<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> FloatArray.sortedByDescending(     selector: (Float) -> R? ): List<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun FloatArray.sortedDescending(): List<Float> ``` **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.FloatArray,%20kotlin.Comparator((kotlin.Float)))/comparator). ``` fun FloatArray.sortedWith(     comparator: Comparator<in Float> ): List<Float> ``` **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 array and not contained by the specified collection. ``` infix fun FloatArray.subtract(     other: Iterable<Float> ): Set<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun FloatArray.sum(): Float ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun FloatArray.sumBy(selector: (Float) -> 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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun FloatArray.sumByDouble(     selector: (Float) -> Double ): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.FloatArray,%20kotlin.Function1((kotlin.Float,%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 FloatArray.sumOf(selector: (Float) -> Double): Double ``` **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 FloatArray.sumOf(selector: (Float) -> Long): Long ``` **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 FloatArray.sumOf(selector: (Float) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun FloatArray.sumOf(     selector: (Float) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun FloatArray.sumOf(     selector: (Float) -> BigInteger ): BigInteger ``` **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.FloatArray,%20kotlin.Int)/n) elements. ``` fun FloatArray.take(n: Int): List<Float> ``` **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.FloatArray,%20kotlin.Int)/n) elements. ``` fun FloatArray.takeLast(n: Int): List<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.takeLastWhile(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.Function1((kotlin.Float,%20kotlin.Boolean)))/predicate). ``` fun FloatArray.takeWhile(     predicate: (Float) -> Boolean ): List<Float> ``` **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.FloatArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Float>> FloatArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun FloatArray.toCValues(): CValues<FloatVar> ``` **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 FloatArray.toHashSet(): HashSet<Float> ``` **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 FloatArray.toList(): List<Float> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun FloatArray.toMutableList(): MutableList<Float> ``` **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 array. ``` fun FloatArray.toMutableSet(): MutableSet<Float> ``` **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 FloatArray.toSet(): Set<Float> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun FloatArray.toSortedSet(): SortedSet<Float> ``` **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 FloatArray.union(     other: Iterable<Float> ): Set<Float> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun FloatArray.withIndex(): Iterable<IndexedValue<Float>> ``` **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.FloatArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Float, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.FloatArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Float,%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.FloatArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Float,%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> FloatArray.zip(     other: Array<out R>,     transform: (a: Float, 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.FloatArray,%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> FloatArray.zip(     other: Iterable<R> ): List<Pair<Float, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.FloatArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Float,%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.FloatArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Float,%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> FloatArray.zip(     other: Iterable<R>,     transform: (a: Float, 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.FloatArray,%20kotlin.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.FloatArray,%20kotlin.FloatArray,%20kotlin.Function2((kotlin.Float,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> FloatArray.zip(     other: FloatArray,     transform: (a: Float, b: Float) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): FloatIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Float) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.FloatArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.FloatArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Float) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/index) to the given [value](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/value). This method can be called using the index operator. If the [index](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/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. ##### For Native Sets the element at the given [index](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/index) to the given [value](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/value). This method can be called using the index operator. If the [index](set#kotlin.FloatArray%24set(kotlin.Int,%20kotlin.Float)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [FloatArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Float ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.FloatArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.FloatArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.FloatArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.FloatArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(element: UInt): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](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 UIntArray UIntArray ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline class UIntArray :      Collection<UInt> ``` 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. ``` UIntArray(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: UInt): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<UInt>): 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.UIntArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): UInt ``` **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<UInt> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.UIntArray%24set(kotlin.Int,%20kotlin.UInt)/index) to the given [value](set#kotlin.UIntArray%24set(kotlin.Int,%20kotlin.UInt)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: UInt) ``` 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 UIntArray.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 UIntArray.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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.all(predicate: (UInt) -> 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 UIntArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.any(predicate: (UInt) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asIntArray](../../kotlin.collections/as-int-array) Returns an array of type [IntArray](../-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](../../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) #### [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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> UIntArray.associateWith(     valueSelector: (UInt) -> V ): Map<UInt, 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.UIntArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UInt,%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.UIntArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in UInt, in V>> UIntArray.associateWithTo(     destination: M,     valueSelector: (UInt) -> 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.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun UIntArray.binarySearch(     element: UInt,     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 UIntArray.component1(): UInt ``` **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 UIntArray.component2(): UInt ``` **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 UIntArray.component3(): UInt ``` **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 UIntArray.component4(): UInt ``` **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 UIntArray.component5(): UInt ``` **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 UIntArray.contentEquals(other: UIntArray): Boolean ``` ``` infix fun UIntArray?.contentEquals(     other: UIntArray? ): 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 UIntArray.contentHashCode(): Int ``` ``` fun UIntArray?.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 UIntArray.contentToString(): String ``` ``` fun UIntArray?.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.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 ``` **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 UIntArray.copyOf(): UIntArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](../../kotlin.collections/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. ``` fun UIntArray.copyOf(newSize: Int): UIntArray ``` **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 UIntArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UIntArray ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.count(predicate: (UInt) -> 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.UIntArray,%20kotlin.Int)/n) elements. ``` fun UIntArray.drop(n: Int): List<UInt> ``` **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.UIntArray,%20kotlin.Int)/n) elements. ``` fun UIntArray.dropLast(n: Int): List<UInt> ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.dropLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.dropWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` 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.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/index) is out of bounds of this array. ``` fun UIntArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` 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.UIntArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.UIntArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UIntArray.elementAtOrNull(index: Int): UInt? ``` **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.UIntArray,%20kotlin.UInt,%20kotlin.Int,%20kotlin.Int)/element) value. ``` fun UIntArray.fill(     element: UInt,     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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.filter(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` 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.UIntArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.filterIndexed(     predicate: (index: Int, UInt) -> Boolean ): List<UInt> ``` ``` 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.UIntArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.UIntArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UInt>> UIntArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.filterNot(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` 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.UIntArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.UIntArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UInt>> UIntArray.filterNotTo(     destination: C,     predicate: (UInt) -> 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.UIntArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.UIntArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UInt>> UIntArray.filterTo(     destination: C,     predicate: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UIntArray.find(predicate: (UInt) -> Boolean): UInt? ``` ``` 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UIntArray.findLast(predicate: (UInt) -> Boolean): UInt? ``` ``` 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 UIntArray.first(): UInt ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.first(predicate: (UInt) -> Boolean): UInt ``` ``` 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 UIntArray.firstOrNull(): UInt? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun UIntArray.firstOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> UIntArray.flatMap(     transform: (UInt) -> 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.UIntArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> UIntArray.flatMapIndexed(     transform: (index: Int, UInt) -> 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.UIntArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%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.UIntArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> UIntArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> 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.UIntArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UInt,%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.UIntArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> UIntArray.flatMapTo(     destination: C,     transform: (UInt) -> 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.UIntArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UInt,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.UIntArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UInt,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> UIntArray.fold(     initial: R,     operation: (acc: R, UInt) -> 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.UIntArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UInt,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.UIntArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UInt,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> UIntArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> 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.UIntArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UInt,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.UIntArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UInt,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> UIntArray.foldRight(     initial: R,     operation: (UInt, 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.UIntArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.UIntArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%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> UIntArray.foldRightIndexed(     initial: R,     operation: (index: Int, UInt, 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Unit)))/action) on each element. ``` fun UIntArray.forEach(action: (UInt) -> 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.UIntArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun UIntArray.forEachIndexed(     action: (index: Int, UInt) -> 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.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UIntArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UInt)))/index) is out of bounds of this array. ``` fun UIntArray.getOrElse(     index: Int,     defaultValue: (Int) -> UInt ): UInt ``` **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.UIntArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.UIntArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UIntArray.getOrNull(index: Int): UInt? ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%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> UIntArray.groupBy(     keySelector: (UInt) -> K ): Map<K, List<UInt>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UInt,%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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UInt,%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> UIntArray.groupBy(     keySelector: (UInt) -> K,     valueTransform: (UInt) -> 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.UIntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UIntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<UInt>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UIntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UInt,%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.UIntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UIntArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UInt,%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>>> UIntArray.groupByTo(     destination: M,     keySelector: (UInt) -> K,     valueTransform: (UInt) -> 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.UIntArray,%20kotlin.UInt)/element), or -1 if the array does not contain element. ``` fun UIntArray.indexOf(element: UInt): 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UIntArray.indexOfFirst(predicate: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UIntArray.indexOfLast(predicate: (UInt) -> 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 UIntArray.last(): UInt ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.last(predicate: (UInt) -> Boolean): UInt ``` ``` 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.UIntArray,%20kotlin.UInt)/element), or -1 if the array does not contain element. ``` fun UIntArray.lastIndexOf(element: UInt): 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 UIntArray.lastOrNull(): UInt? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UIntArray.lastOrNull(predicate: (UInt) -> Boolean): UInt? ``` ``` 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> UIntArray.map(transform: (UInt) -> 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.UIntArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> UIntArray.mapIndexed(     transform: (index: Int, UInt) -> 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.UIntArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%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.UIntArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UIntArray.mapIndexedTo(     destination: C,     transform: (index: Int, UInt) -> 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.UIntArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UInt,%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.UIntArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UIntArray.mapTo(     destination: C,     transform: (UInt) -> 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>> UIntArray.maxByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UIntArray.maxOf(selector: (UInt) -> Double): Double ``` ``` fun UIntArray.maxOf(selector: (UInt) -> Float): Float ``` ``` fun <R : Comparable<R>> UIntArray.maxOf(     selector: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UIntArray.maxOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` fun UIntArray.maxOfOrNull(selector: (UInt) -> Float): Float? ``` ``` fun <R : Comparable<R>> UIntArray.maxOfOrNull(     selector: (UInt) -> 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.UIntArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.UIntArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UIntArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> 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.UIntArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.UIntArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UIntArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> 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 UIntArray.maxOrNull(): UInt? ``` #### [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.UIntArray,%20kotlin.Comparator((kotlin.UInt)))/comparator). ``` fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UIntArray.maxWith(comparator: Comparator<in UInt>): UInt? ``` **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.UIntArray,%20kotlin.Comparator((kotlin.UInt)))/comparator) or `null` if there are no elements. ``` fun UIntArray.maxWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` 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>> UIntArray.minByOrNull(     selector: (UInt) -> R ): UInt? ``` ``` 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UIntArray.minOf(selector: (UInt) -> Double): Double ``` ``` fun UIntArray.minOf(selector: (UInt) -> Float): Float ``` ``` fun <R : Comparable<R>> UIntArray.minOf(     selector: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UIntArray.minOfOrNull(     selector: (UInt) -> Double ): Double? ``` ``` fun UIntArray.minOfOrNull(selector: (UInt) -> Float): Float? ``` ``` fun <R : Comparable<R>> UIntArray.minOfOrNull(     selector: (UInt) -> 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.UIntArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.UIntArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UIntArray.minOfWith(     comparator: Comparator<in R>,     selector: (UInt) -> 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.UIntArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.UIntArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UInt,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UIntArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UInt) -> 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 UIntArray.minOrNull(): UInt? ``` **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.UIntArray,%20kotlin.Comparator((kotlin.UInt)))/comparator). ``` fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UIntArray.minWith(comparator: Comparator<in UInt>): UInt? ``` **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.UIntArray,%20kotlin.Comparator((kotlin.UInt)))/comparator) or `null` if there are no elements. ``` fun UIntArray.minWithOrNull(     comparator: Comparator<in UInt> ): UInt? ``` ``` 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 UIntArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.none(predicate: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun UIntArray.onEach(action: (UInt) -> Unit): UIntArray ``` 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.UIntArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UInt,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun UIntArray.onEachIndexed(     action: (index: Int, UInt) -> Unit ): UIntArray ``` 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.UIntArray,%20kotlin.UInt)/element). ``` operator fun UIntArray.plus(element: UInt): UIntArray ``` 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.UIntArray,%20kotlin.collections.Collection((kotlin.UInt)))/elements) collection. ``` operator fun UIntArray.plus(     elements: Collection<UInt> ): UIntArray ``` 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.UIntArray,%20kotlin.UIntArray)/elements) array. ``` operator fun UIntArray.plus(elements: UIntArray): UIntArray ``` 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 UIntArray.random(): UInt ``` Returns a random element from this array using the specified source of randomness. ``` fun UIntArray.random(random: Random): UInt ``` **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 UIntArray.randomOrNull(): UInt? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun UIntArray.randomOrNull(random: Random): UInt? ``` **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.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UIntArray.reduce(     operation: (acc: UInt, UInt) -> UInt ): UInt ``` ``` 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.UIntArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UIntArray.reduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt ``` 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.UIntArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UIntArray.reduceIndexedOrNull(     operation: (index: Int, acc: UInt, UInt) -> UInt ): UInt? ``` 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.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UIntArray.reduceOrNull(     operation: (acc: UInt, UInt) -> UInt ): UInt? ``` ``` 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.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UIntArray.reduceRight(     operation: (UInt, acc: UInt) -> UInt ): UInt ``` **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.UIntArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UIntArray.reduceRightIndexed(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt ``` **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.UIntArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UIntArray.reduceRightIndexedOrNull(     operation: (index: Int, UInt, acc: UInt) -> UInt ): UInt? ``` **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.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UIntArray.reduceRightOrNull(     operation: (UInt, acc: UInt) -> UInt ): UInt? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun UIntArray.refTo(index: Int): CValuesRef<UIntVar> ``` **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 UIntArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun UIntArray.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 UIntArray.reversed(): List<UInt> ``` **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 UIntArray.reversedArray(): UIntArray ``` **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.UIntArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UInt,%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.UIntArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UInt,%20)))/initial) value. ``` fun <R> UIntArray.runningFold(     initial: R,     operation: (acc: R, UInt) -> 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.UIntArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UInt,%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.UIntArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UInt,%20)))/initial) value. ``` fun <R> UIntArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> 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.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. ``` fun UIntArray.runningReduce(     operation: (acc: UInt, UInt) -> UInt ): List<UInt> ``` 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.UIntArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UInt,%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 UIntArray.runningReduceIndexed(     operation: (index: Int, acc: UInt, UInt) -> UInt ): List<UInt> ``` 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.UIntArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UInt,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.UIntArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UInt,%20)))/initial) value. ``` fun <R> UIntArray.scan(     initial: R,     operation: (acc: R, UInt) -> 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.UIntArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UInt,%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.UIntArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UInt,%20)))/initial) value. ``` fun <R> UIntArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UInt) -> 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 UIntArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.UIntArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun UIntArray.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 UIntArray.single(): UInt ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun UIntArray.single(predicate: (UInt) -> Boolean): UInt ``` ``` 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 UIntArray.singleOrNull(): UInt? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun UIntArray.singleOrNull(     predicate: (UInt) -> Boolean ): UInt? ``` ``` 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.UIntArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UIntArray.slice(indices: IntRange): List<UInt> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.UIntArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun UIntArray.slice(indices: Iterable<Int>): List<UInt> ``` **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.UIntArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun UIntArray.sliceArray(indices: Collection<Int>): UIntArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.UIntArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UIntArray.sliceArray(indices: IntRange): UIntArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sort](../../kotlin.collections/sort) Sorts the array in-place. ``` fun UIntArray.sort() ``` Sorts a range in the array in-place. ``` fun UIntArray.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 UIntArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun UIntArray.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 UIntArray.sorted(): List<UInt> ``` **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 UIntArray.sortedArray(): UIntArray ``` **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 UIntArray.sortedArrayDescending(): UIntArray ``` **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 UIntArray.sortedDescending(): List<UInt> ``` **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 UIntArray.sum(): UInt ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20)))/selector) function applied to each element in the array. ``` fun UIntArray.sumBy(selector: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UIntArray.sumByDouble(selector: (UInt) -> 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.UIntArray,%20kotlin.Function1((kotlin.UInt,%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 UIntArray.sumOf(selector: (UInt) -> 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 UIntArray.sumOf(selector: (UInt) -> 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 UIntArray.sumOf(selector: (UInt) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun UIntArray.sumOf(     selector: (UInt) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UIntArray.sumOf(     selector: (UInt) -> 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.UIntArray,%20kotlin.Int)/n) elements. ``` fun UIntArray.take(n: Int): List<UInt> ``` **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.UIntArray,%20kotlin.Int)/n) elements. ``` fun UIntArray.takeLast(n: Int): List<UInt> ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.takeLastWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` **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.UIntArray,%20kotlin.Function1((kotlin.UInt,%20kotlin.Boolean)))/predicate). ``` fun UIntArray.takeWhile(     predicate: (UInt) -> Boolean ): List<UInt> ``` ``` 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 UIntArray.toCValues(): CValues<UIntVar> ``` **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.3), JS (1.3), Native (1.3) #### [toIntArray](../../kotlin.collections/to-int-array) Returns an array of type [IntArray](../-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](../../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) #### [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 UIntArray.toTypedArray(): Array<UInt> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUIntArray](../../kotlin.collections/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.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 UIntArray.withIndex(): Iterable<IndexedValue<UInt>> ``` **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.UIntArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> UIntArray.zip(     other: Array<out R> ): List<Pair<UInt, R>> ``` ``` infix fun UIntArray.zip(     other: UIntArray ): List<Pair<UInt, UInt>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UIntArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UInt,%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.UIntArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UInt,%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> UIntArray.zip(     other: Array<out R>,     transform: (a: UInt, 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.UIntArray,%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> UIntArray.zip(     other: Iterable<R> ): List<Pair<UInt, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UIntArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UInt,%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.UIntArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UInt,%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> UIntArray.zip(     other: Iterable<R>,     transform: (a: UInt, 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.UIntArray,%20kotlin.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UIntArray,%20kotlin.UIntArray,%20kotlin.Function2((kotlin.UInt,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> UIntArray.zip(     other: UIntArray,     transform: (a: UInt, b: UInt) -> 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) / [UIntArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun iterator(): Iterator<UInt> ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` UIntArray(size: Int) ``` Creates a new array of the specified size, with all elements initialized to zero. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun containsAll(elements: Collection<UInt>): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UIntArray](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) / [UIntArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun set(index: Int, value: UInt) ``` Sets the element at the given [index](set#kotlin.UIntArray%24set(kotlin.Int,%20kotlin.UInt)/index) to the given [value](set#kotlin.UIntArray%24set(kotlin.Int,%20kotlin.UInt)/value). This method can be called using the index operator. If the [index](set#kotlin.UIntArray%24set(kotlin.Int,%20kotlin.UInt)/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) / [UIntArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun get(index: Int): UInt ``` Returns the array element at the given [index](get#kotlin.UIntArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.UIntArray%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 Throws Throws ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throws](index) **Platform and version requirements:** ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.CONSTRUCTOR]) annotation class Throws ``` **Platform and version requirements:** JVM (1.4) ``` typealias Throws = Throws ``` **Platform and version requirements:** Native (1.4) ``` @Target([AnnotationTarget.FUNCTION, AnnotationTarget.CONSTRUCTOR]) annotation class Throws ``` ##### For JVM This annotation indicates what exceptions should be declared by a function when compiled to a JVM method. Example: ``` @Throws(IOException::class) fun readFile(name: String): String {...} ``` will be translated to ``` String readFile(String name) throws IOException {...} ``` ##### For Common This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. ##### For Native This annotation indicates what exceptions should be declared by a function when compiled to a platform method. When compiling to Objective-C/Swift framework, non-`suspend` functions having or inheriting this annotation are represented as `NSError*`-producing methods in Objective-C and as `throws` methods in Swift. Representations for `suspend` functions always have `NSError*`/`Error` parameter in completion handler When Kotlin function called from Swift/Objective-C code throws an exception which is an instance of one of the [exceptionClasses](exception-classes#kotlin.Throws%24exceptionClasses) or their subclasses, it is propagated as `NSError`. Other Kotlin exceptions reaching Swift/Objective-C are considered unhandled and cause program termination. Note: `suspend` functions without `@Throws` propagate only [kotlin.coroutines.cancellation.CancellationException](../../kotlin.coroutines.cancellation/-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) as `NSError`. Non-`suspend` functions without `@Throws` don't propagate Kotlin exceptions at all. Constructors ------------ **Platform and version requirements:** Native (1.0) #### [<init>](-init-) This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. ``` <init>(vararg exceptionClasses: KClass<out Throwable>) ``` Properties ---------- **Platform and version requirements:** Native (1.0) #### [exceptionClasses](exception-classes) the list of checked exception classes that may be thrown by the function. ``` vararg val exceptionClasses: Array<out KClass<out Throwable>> ``` kotlin exceptionClasses exceptionClasses ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throws](index) / [exceptionClasses](exception-classes) **Platform and version requirements:** Native (1.3) ``` vararg val exceptionClasses: Array<out KClass<out Throwable>> ``` the list of checked exception classes that may be thrown by the function. Property -------- `exceptionClasses` - the list of checked exception classes that may be thrown by the function. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Throws](index) / [<init>](-init-) **Platform and version requirements:** Native (1.3) ``` <init>(vararg exceptionClasses: KClass<out Throwable>) ``` ##### For Common This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. ##### For Native This annotation indicates what exceptions should be declared by a function when compiled to a platform method. When compiling to Objective-C/Swift framework, non-`suspend` functions having or inheriting this annotation are represented as `NSError*`-producing methods in Objective-C and as `throws` methods in Swift. Representations for `suspend` functions always have `NSError*`/`Error` parameter in completion handler When Kotlin function called from Swift/Objective-C code throws an exception which is an instance of one of the [exceptionClasses](exception-classes#kotlin.Throws%24exceptionClasses) or their subclasses, it is propagated as `NSError`. Other Kotlin exceptions reaching Swift/Objective-C are considered unhandled and cause program termination. Note: `suspend` functions without `@Throws` propagate only [kotlin.coroutines.cancellation.CancellationException](../../kotlin.coroutines.cancellation/-cancellation-exception/index#kotlin.coroutines.cancellation.CancellationException) as `NSError`. Non-`suspend` functions without `@Throws` don't propagate Kotlin exceptions at all. kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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 Int in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Returns this value. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toByte(): Byte ``` Converts this [Int](index#kotlin.Int) 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 `Int`. The resulting `Byte` value is represented by the least significant 8 bits of this `Int` value. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Int ``` Returns this value. kotlin shr shr === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <shr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun shr(bitCount: Int): Int ``` Shifts this value right by the [bitCount](shr#kotlin.Int%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with copies of the sign bit. Note that only the five lowest-order bits of the [bitCount](shr#kotlin.Int%24shr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..31`. kotlin Int Int === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Int : Number, Comparable<Int> ``` ##### For Common, JVM, JS Represents a 32-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `int`. ##### For Native Represents a 32-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: Int): Int ``` **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(): Int ``` **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): 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. ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Int): 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(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): Int ``` **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): 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 ``` **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: Int): Int ``` **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): 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 ``` **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.Int%24rangeTo(kotlin.Byte)/other) value. ``` operator fun rangeTo(other: Byte): IntRange ``` ``` operator fun rangeTo(other: Short): IntRange ``` ``` operator fun rangeTo(other: Int): IntRange ``` ``` 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.Int%24rangeUntil(kotlin.Byte)/other) value. ``` operator fun rangeUntil(other: Byte): IntRange ``` ``` operator fun rangeUntil(other: Short): IntRange ``` ``` operator fun rangeUntil(other: Int): IntRange ``` ``` 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): 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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shl> Shifts this value left by the [bitCount](shl#kotlin.Int%24shl(kotlin.Int)/bitCount) number of bits. ``` infix fun shl(bitCount: Int): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shr> Shifts this value right by the [bitCount](shr#kotlin.Int%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with copies of the sign bit. ``` infix fun shr(bitCount: Int): Int ``` **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): 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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [Int](index#kotlin.Int) 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 [Int](index#kotlin.Int) 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 [Int](index#kotlin.Int) 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 [Int](index#kotlin.Int) 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) Returns this value. ``` fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Converts this [Int](index#kotlin.Int) 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 [Int](index#kotlin.Int) 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(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <ushr> Shifts this value right by the [bitCount](ushr#kotlin.Int%24ushr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. ``` infix fun ushr(bitCount: Int): Int ``` **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: Int): Int ``` 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 Int can have. ``` const val MAX_VALUE: Int ``` **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 Int can have. ``` const val MIN_VALUE: Int ``` **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 Int 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 Int 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 [Int](index#kotlin.Int) number of days. ``` val Int.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 [Int](index#kotlin.Int) number of hours. ``` val Int.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 [Int](index#kotlin.Int) number of microseconds. ``` val Int.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 [Int](index#kotlin.Int) number of milliseconds. ``` val Int.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 [Int](index#kotlin.Int) number of minutes. ``` val Int.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 [Int](index#kotlin.Int) number of nanoseconds. ``` val Int.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 [Int](index#kotlin.Int) number of seconds. ``` val Int.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.Int,%20kotlin.Int)/minimumValue). ``` fun Int.coerceAtLeast(minimumValue: Int): Int ``` ``` 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.Int,%20kotlin.Int)/maximumValue). ``` fun Int.coerceAtMost(maximumValue: Int): Int ``` ``` 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.Int,%20kotlin.Int,%20kotlin.Int)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/maximumValue). ``` fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int ``` ``` 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.Int,%20kotlin.ranges.ClosedRange((kotlin.Int)))/range). ``` fun Int.coerceIn(range: ClosedRange<Int>): Int ``` ``` 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> Int.convert(): R ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [digitToChar](../../kotlin.text/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](../../kotlin.text/digit-to-char#kotlin.text%24digitToChar(kotlin.Int,%20kotlin.Int)/radix). Throws an exception if the [radix](../../kotlin.text/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.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.Int,%20kotlin.Byte)/to) value with the step -1. ``` infix fun Int.downTo(to: Byte): IntProgression ``` ``` infix fun Int.downTo(to: Int): IntProgression ``` ``` infix fun Int.downTo(to: Long): LongProgression ``` ``` infix fun Int.downTo(to: Short): IntProgression ``` **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 Int.floorDiv(other: Byte): Int ``` ``` fun Int.floorDiv(other: Short): Int ``` ``` fun Int.floorDiv(other: Int): Int ``` ``` fun Int.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 Int.mod(other: Byte): Byte ``` ``` fun Int.mod(other: Short): Short ``` ``` fun Int.mod(other: Int): Int ``` ``` fun Int.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.6), JS (1.6), Native (1.6) #### [times](../../kotlin.time/times) Returns a duration whose value is the specified [duration](../../kotlin.time/times#kotlin.time%24times(kotlin.Int,%20kotlin.time.Duration)/duration) value multiplied by this number. ``` operator fun Int.times(duration: Duration): Duration ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](../to-big-decimal) Returns the value of this [Int](index#kotlin.Int) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Int.toBigDecimal(): BigDecimal ``` ``` fun Int.toBigDecimal(mathContext: MathContext): BigDecimal ``` **Platform and version requirements:** JVM (1.2) #### [toBigInteger](../to-big-integer) Returns the value of this [Int](index#kotlin.Int) number as a [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html). ``` fun Int.toBigInteger(): BigInteger ``` **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 [Int](index#kotlin.Int) number of the specified [unit](../../kotlin.time/to-duration#kotlin.time%24toDuration(kotlin.Int,%20kotlin.time.DurationUnit)/unit). ``` fun Int.toDuration(unit: DurationUnit): Duration ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](../to-u-byte) Converts this [Int](index#kotlin.Int) value to [UByte](../-u-byte/index). ``` fun Int.toUByte(): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Int](index#kotlin.Int) value to [UInt](../-u-int/index). ``` fun Int.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Int](index#kotlin.Int) value to [ULong](../-u-long/index). ``` fun Int.toULong(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](../to-u-short) Converts this [Int](index#kotlin.Int) value to [UShort](../-u-short/index). ``` fun Int.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.Int,%20kotlin.Byte)/to) value. ``` infix fun Int.until(to: Byte): IntRange ``` ``` infix fun Int.until(to: Int): IntRange ``` ``` infix fun Int.until(to: Long): LongRange ``` ``` infix fun Int.until(to: Short): IntRange ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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 Int in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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: Int ``` A constant holding the minimum value an instance of Int can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Converts this [Int](index#kotlin.Int) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `Int`. The least significant 32 bits of the resulting `Long` value are the same as the bits of this `Int` value, whereas the most significant 32 bits are filled with the sign bit of this value. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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: Int ``` A constant holding the maximum value an instance of Int can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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) / [Int](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.Int%24rangeTo(kotlin.Byte)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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 shl shl === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <shl> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun shl(bitCount: Int): Int ``` Shifts this value left by the [bitCount](shl#kotlin.Int%24shl(kotlin.Int)/bitCount) number of bits. Note that only the five lowest-order bits of the [bitCount](shl#kotlin.Int%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) / [Int](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.Int%24rangeUntil(kotlin.Byte)/other) value. If the [other](range-until#kotlin.Int%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) / [Int](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) / [Int](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Converts this [Int](index#kotlin.Int) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `Int`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Int ``` 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) / [Int](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) / [Int](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun and(other: Int): Int ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Int ``` 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) / [Int](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun inv(): Int ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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) / [Int](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 xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun xor(other: Int): Int ``` Performs a bitwise XOR operation between the two values. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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: Int): Boolean ``` kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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) / [Int](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Converts this [Int](index#kotlin.Int) value to [Float](../-float/index#kotlin.Float). The resulting value is the closest `Float` to this `Int` value. In case when this `Int` 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) / [Int](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 ushr ushr ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <ushr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun ushr(bitCount: Int): Int ``` Shifts this value right by the [bitCount](ushr#kotlin.Int%24ushr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. Note that only the five lowest-order bits of the [bitCount](ushr#kotlin.Int%24ushr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..31`. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toShort(): Short ``` Converts this [Int](index#kotlin.Int) 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 `Int`. The resulting `Short` value is represented by the least significant 16 bits of this `Int` value. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](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 or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` infix fun or(other: Int): Int ``` Performs a bitwise OR operation between the two values. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Int](index) / [toChar](to-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toChar(): Char ``` Converts this [Int](index#kotlin.Int) 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 `Int` value. kotlin ExperimentalStdlibApi ExperimentalStdlibApi ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalStdlibApi](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @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 ExperimentalStdlibApi ``` This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. Beware using the annotated API especially if you're developing a library, since your library might become binary incompatible with the future versions of the standard library. Any usage of a declaration annotated with `@ExperimentalStdlibApi` must be accepted either by annotating that usage with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalStdlibApi::class)`, or by using the compiler argument `-opt-in=kotlin.ExperimentalStdlibApi`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. ``` ExperimentalStdlibApi() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalStdlibApi](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ExperimentalStdlibApi() ``` This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. Beware using the annotated API especially if you're developing a library, since your library might become binary incompatible with the future versions of the standard library. Any usage of a declaration annotated with `@ExperimentalStdlibApi` must be accepted either by annotating that usage with the [OptIn](../-opt-in/index) annotation, e.g. `@OptIn(ExperimentalStdlibApi::class)`, or by using the compiler argument `-opt-in=kotlin.ExperimentalStdlibApi`. kotlin Any Any === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Any](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open class Any ``` The root of the Kotlin class hierarchy. Every Kotlin class has [Any](index#kotlin.Any) as a superclass. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) The root of the Kotlin class hierarchy. Every Kotlin class has [Any](index#kotlin.Any) as a superclass. ``` <init>() ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements: ``` open operator fun equals(other: Any?): Boolean ``` **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: ``` open fun hashCode(): Int ``` **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:** Native (1.3) #### [isFrozen](../../kotlin.native.concurrent/is-frozen) Checks if given object is null or frozen or permanent (i.e. instantiated at compile-time). ``` val Any?.isFrozen: Boolean ``` **Platform and version requirements:** JVM (1.0) #### [javaClass](../../kotlin.jvm/java-class) Returns the runtime Java class of this object. ``` val <T : Any> T.javaClass: Class<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [also](../also) Calls the specified function [block](../also#kotlin%24also(kotlin.also.T,%20kotlin.Function1((kotlin.also.T,%20kotlin.Unit)))/block) with `this` value as its argument and returns `this` value. ``` fun <T> T.also(block: (T) -> Unit): T ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [apply](../apply) Calls the specified function [block](../apply#kotlin%24apply(kotlin.apply.T,%20kotlin.Function1((kotlin.apply.T,%20kotlin.Unit)))/block) with `this` value as its receiver and returns `this` value. ``` fun <T> T.apply(block: T.() -> Unit): T ``` **Platform and version requirements:** JS (1.1) #### [asDynamic](../../kotlin.js/as-dynamic) Reinterprets this value as a value of the [dynamic type](../../../../../../docs/dynamic-type). ``` fun Any?.asDynamic(): dynamic ``` **Platform and version requirements:** Native (1.3) #### [ensureNeverFrozen](../../kotlin.native.concurrent/ensure-never-frozen) This function ensures that if we see such an object during freezing attempt - freeze fails and [FreezingException](../../kotlin.native.concurrent/-freezing-exception/index) is thrown. ``` fun Any.ensureNeverFrozen() ``` **Platform and version requirements:** Native (1.3) #### [freeze](../../kotlin.native.concurrent/freeze) Freezes object subgraph reachable from this object. Frozen objects can be freely shared between threads/workers. ``` fun <T> T.freeze(): T ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [hashCode](../hash-code) Returns a hash code value for the object or zero if the object is `null`. ``` fun Any?.hashCode(): Int ``` **Platform and version requirements:** Native (1.3) #### [identityHashCode](../../kotlin.native/identity-hash-code) Compute stable wrt potential object relocations by the memory manager identity hash code. ``` fun Any?.identityHashCode(): Int ``` **Platform and version requirements:** JS (1.1) #### [iterator](../../kotlin.js/iterator) Allows to iterate this `dynamic` object in the following cases: ``` operator fun dynamic.iterator(): Iterator<dynamic> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [let](../let) Calls the specified function [block](../let#kotlin%24let(kotlin.let.T,%20kotlin.Function1((kotlin.let.T,%20kotlin.let.R)))/block) with `this` value as its argument and returns its result. ``` fun <T, R> T.let(block: (T) -> R): R ``` **Platform and version requirements:** Native (1.3) #### [objcPtr](../../kotlinx.cinterop/objc-ptr) ``` fun Any?.objcPtr(): NativePtr ``` **Platform and version requirements:** Native (1.3) #### [pin](../../kotlinx.cinterop/pin) ``` fun <T : Any> T.pin(): Pinned<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [run](../run) Calls the specified function [block](../run#kotlin%24run(kotlin.run.T,%20kotlin.Function1((kotlin.run.T,%20kotlin.run.R)))/block) with `this` value as its receiver and returns its result. ``` fun <T, R> T.run(block: T.() -> R): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [runCatching](../run-catching) Calls the specified function [block](../run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) with `this` value as its receiver and returns its encapsulated result if invocation was successful, catching any [Throwable](../-throwable/index#kotlin.Throwable) exception that was thrown from the [block](../run-catching#kotlin%24runCatching(kotlin.runCatching.T,%20kotlin.Function1((kotlin.runCatching.T,%20kotlin.runCatching.R)))/block) function execution and encapsulating it as a failure. ``` fun <T, R> T.runCatching(block: T.() -> R): Result<R> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [takeIf](../take-if) Returns `this` value if it satisfies the given [predicate](../take-if#kotlin%24takeIf(kotlin.takeIf.T,%20kotlin.Function1((kotlin.takeIf.T,%20kotlin.Boolean)))/predicate) or `null`, if it doesn't. ``` fun <T> T.takeIf(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [takeUnless](../take-unless) Returns `this` value if it *does not* satisfy the given [predicate](../take-unless#kotlin%24takeUnless(kotlin.takeUnless.T,%20kotlin.Function1((kotlin.takeUnless.T,%20kotlin.Boolean)))/predicate) or `null`, if it does. ``` fun <T> T.takeUnless(predicate: (T) -> Boolean): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [to](../to) Creates a tuple of type [Pair](../-pair/index) from this and [that](../to#kotlin%24to(kotlin.to.A,%20kotlin.to.B)/that). ``` infix fun <A, B> A.to(that: B): Pair<A, B> ``` **Platform and version requirements:** JS (1.1) #### [unsafeCast](../../kotlin.js/unsafe-cast) Reinterprets this value as a value of the specified type [T](../../kotlin.js/unsafe-cast#T) without any actual type checking. ``` fun <T> Any?.unsafeCast(): T ``` Reinterprets this `dynamic` value as a value of the specified type [T](../../kotlin.js/unsafe-cast#T) without any actual type checking. ``` fun <T> dynamic.unsafeCast(): T ``` **Platform and version requirements:** Native (1.3) #### [usePinned](../../kotlinx.cinterop/use-pinned) ``` fun <T : Any, R> T.usePinned(block: (Pinned<T>) -> R): R ``` Inheritors ---------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractCollection](../../kotlin.collections/-abstract-collection/index) Provides a skeletal implementation of the read-only [Collection](../../kotlin.collections/-collection/index#kotlin.collections.Collection) interface. ``` abstract class AbstractCollection<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [AbstractCoroutineContextElement](../../kotlin.coroutines/-abstract-coroutine-context-element/index) Base class for [CoroutineContext.Element](../../kotlin.coroutines/-coroutine-context/-element/index) implementations. ``` abstract class AbstractCoroutineContextElement : Element ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [AbstractCoroutineContextKey](../../kotlin.coroutines/-abstract-coroutine-context-key/index) Base class for [CoroutineContext.Key](../../kotlin.coroutines/-coroutine-context/-key) associated with polymorphic [CoroutineContext.Element](../../kotlin.coroutines/-coroutine-context/-element/index) implementation. Polymorphic element implementation implies delegating its [get](../../kotlin.coroutines/-coroutine-context/-element/get) and [minusKey](../../kotlin.coroutines/-coroutine-context/-element/minus-key) to [getPolymorphicElement](../../kotlin.coroutines/get-polymorphic-element) and [minusPolymorphicKey](../../kotlin.coroutines/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) #### [AbstractDoubleTimeSource](../../kotlin.time/-abstract-double-time-source/index) An abstract class used to implement time sources that return their readings as [Double](../-double/index#kotlin.Double) values in the specified [unit](../../kotlin.time/-abstract-double-time-source/unit). ``` abstract class AbstractDoubleTimeSource : WithComparableMarks ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [AbstractIterator](../../kotlin.collections/-abstract-iterator/index) A base class to simplify implementing iterators so that implementations only have to implement [computeNext](../../kotlin.collections/-abstract-iterator/compute-next) to implement the iterator, calling [done](../../kotlin.collections/-abstract-iterator/done) when the iteration is complete. ``` abstract class AbstractIterator<T> : Iterator<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [AbstractLongTimeSource](../../kotlin.time/-abstract-long-time-source/index) An abstract class used to implement time sources that return their readings as [Long](../-long/index#kotlin.Long) values in the specified [unit](../../kotlin.time/-abstract-long-time-source/unit). ``` abstract class AbstractLongTimeSource : WithComparableMarks ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [AbstractMap](../../kotlin.collections/-abstract-map/index) Provides a skeletal implementation of the read-only [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) interface. ``` abstract class AbstractMap<K, out V> : Map<K, V> ``` #### [AbstractMutableCollection](../../kotlin.collections/-abstract-mutable-collection/index) Provides a skeletal implementation of the [MutableCollection](../../kotlin.collections/-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](../../kotlin.collections/-abstract-mutable-list/index) Provides a skeletal implementation of the [MutableList](../../kotlin.collections/-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](../../kotlin.collections/-abstract-mutable-map/index) Provides a skeletal implementation of the [MutableMap](../../kotlin.collections/-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](../../kotlin.collections/-abstract-mutable-set/index) Provides a skeletal implementation of the [MutableSet](../../kotlin.collections/-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:** JS (1.1) #### [AbstractWorker](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-abstract-worker/index.html) Exposes the JavaScript [AbstractWorker](https://developer.mozilla.org/en/docs/Web/API/AbstractWorker) to Kotlin ``` interface AbstractWorker ``` **Platform and version requirements:** JVM (1.0) #### [Accessor](../../kotlin.reflect/-k-property/-accessor/index) Represents a property accessor, which is a `get` or `set` method declared alongside the property. See the [Kotlin language documentation](../../../../../../docs/properties#getters-and-setters) for more information. ``` interface Accessor<out V> ``` **Platform and version requirements:** JS (1.1) #### [AddEventListenerOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-add-event-listener-options/index.html) ``` interface AddEventListenerOptions : EventListenerOptions ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Annotation](../-annotation) Base interface implicitly implemented by all annotation interfaces. See [Kotlin language documentation](../../../../../../docs/annotations) for more information on annotations. ``` interface Annotation ``` #### [Appendable](../../kotlin.text/-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:** JS (1.1) #### [AppendMode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediasource/-append-mode.html) ``` interface AppendMode ``` **Platform and version requirements:** Native (1.3) #### [ArenaManager](../../kotlinx.wasm.jsinterop/-arena-manager/index) ``` object ArenaManager ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Array](../-array/index) Represents an array (specifically, a Java array when targeting the JVM platform). Array instances can be created using the [arrayOf](../array-of#kotlin%24arrayOf(kotlin.Array((kotlin.arrayOf.T)))), [arrayOfNulls](../array-of-nulls#kotlin%24arrayOfNulls(kotlin.Int)) and [emptyArray](../empty-array#kotlin%24emptyArray()) standard library functions. See [Kotlin language documentation](../../../../../../docs/basic-types#arrays) for more information on arrays. ``` class Array<T> ``` **Platform and version requirements:** JS (1.1) #### [ArrayBuffer](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-array-buffer/index.html) Exposes the JavaScript [ArrayBuffer](https://developer.mozilla.org/en/docs/Web/API/ArrayBuffer) to Kotlin ``` open class ArrayBuffer : BufferDataSource ``` **Platform and version requirements:** JS (1.1) #### [ArrayBufferView](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-array-buffer-view/index.html) Exposes the JavaScript [ArrayBufferView](https://developer.mozilla.org/en/docs/Web/API/ArrayBufferView) to Kotlin ``` interface ArrayBufferView : BufferDataSource ``` #### [ArrayList](../../kotlin.collections/-array-list/index) Provides a [MutableList](../../kotlin.collections/-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:** JS (1.1) #### [AssignedNodesOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-assigned-nodes-options/index.html) ``` interface AssignedNodesOptions ``` **Platform and version requirements:** JS (1.1), Native (1.1) #### [AssociatedObjectKey](../../kotlin.reflect/-associated-object-key/index) Makes the annotated annotation class an associated object key. ``` annotation class AssociatedObjectKey ``` **Platform and version requirements:** Native (1.3) #### [AtomicInt](../../kotlin.native.concurrent/-atomic-int/index) Wrapper around [Int](../-int/index#kotlin.Int) with atomic synchronized operations. ``` class AtomicInt ``` **Platform and version requirements:** Native (1.3) #### [AtomicLong](../../kotlin.native.concurrent/-atomic-long/index) Wrapper around [Long](../-long/index#kotlin.Long) with atomic synchronized operations. ``` class AtomicLong ``` **Platform and version requirements:** Native (1.3) #### [AtomicNativePtr](../../kotlin.native.concurrent/-atomic-native-ptr/index) Wrapper around [kotlinx.cinterop.NativePtr](../../kotlinx.cinterop/-native-ptr) with atomic synchronized operations. ``` class AtomicNativePtr ``` **Platform and version requirements:** Native (1.3) #### [AtomicReference](../../kotlin.native.concurrent/-atomic-reference/index) Wrapper around Kotlin object with atomic operations. ``` class AtomicReference<T> ``` **Platform and version requirements:** JS (1.1) #### [AudioTrack](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-audio-track/index.html) Exposes the JavaScript [AudioTrack](https://developer.mozilla.org/en/docs/Web/API/AudioTrack) to Kotlin ``` abstract class AudioTrack :      UnionAudioTrackOrTextTrackOrVideoTrack ``` **Platform and version requirements:** JS (1.1) #### [BarProp](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-bar-prop/index.html) ``` abstract class BarProp ``` **Platform and version requirements:** JS (1.1) #### [BinaryType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-binary-type.html) ``` interface BinaryType ``` **Platform and version requirements:** Native (1.3) #### [BitSet](../../kotlin.native/-bit-set/index) A vector of bits growing if necessary and allowing one to set/clear/read bits from it by a bit index. ``` class BitSet ``` **Platform and version requirements:** JS (1.1) #### [Blob](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-blob/index.html) Exposes the JavaScript [Blob](https://developer.mozilla.org/en/docs/Web/API/Blob) to Kotlin ``` open class Blob : MediaProvider, ImageBitmapSource ``` **Platform and version requirements:** JS (1.1) #### [BlobPropertyBag](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-blob-property-bag/index.html) ``` interface BlobPropertyBag ``` **Platform and version requirements:** JS (1.1) #### [Body](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-body/index.html) Exposes the JavaScript [Body](https://developer.mozilla.org/en/docs/Web/API/Body) to Kotlin ``` interface Body ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Boolean](../-boolean/index) Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are represented as values of the primitive type `boolean`. ``` class Boolean : Comparable<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BooleanArray](../-boolean-array/index) An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`. ``` class BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [BooleanIterator](../../kotlin.collections/-boolean-iterator/index) An iterator over a sequence of values of type `Boolean`. ``` abstract class BooleanIterator : Iterator<Boolean> ``` **Platform and version requirements:** JS (1.1) #### [BoxQuadOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-box-quad-options/index.html) ``` interface BoxQuadOptions ``` **Platform and version requirements:** JS (1.1) #### [BufferDataSource](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-buffer-data-source.html) ``` interface BufferDataSource ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [BuilderInference](../-builder-inference/index) Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. ``` annotation class BuilderInference ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ByteArray](../-byte-array/index) An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`. ``` class ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ByteIterator](../../kotlin.collections/-byte-iterator/index) An iterator over a sequence of values of type `Byte`. ``` abstract class ByteIterator : Iterator<Byte> ``` **Platform and version requirements:** JS (1.1) #### [Cache](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-cache/index.html) Exposes the JavaScript [Cache](https://developer.mozilla.org/en/docs/Web/API/Cache) to Kotlin ``` abstract class Cache ``` **Platform and version requirements:** JS (1.1) #### [CacheBatchOperation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-cache-batch-operation/index.html) ``` interface CacheBatchOperation ``` **Platform and version requirements:** JS (1.1) #### [CacheQueryOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-cache-query-options/index.html) ``` interface CacheQueryOptions ``` **Platform and version requirements:** JS (1.1) #### [CacheStorage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-cache-storage/index.html) Exposes the JavaScript [CacheStorage](https://developer.mozilla.org/en/docs/Web/API/CacheStorage) to Kotlin ``` abstract class CacheStorage ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [CallsInPlace](../../kotlin.contracts/-calls-in-place) An effect of calling a functional parameter in place. ``` interface CallsInPlace : Effect ``` **Platform and version requirements:** JS (1.1) #### [CanPlayTypeResult](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-can-play-type-result.html) ``` interface CanPlayTypeResult ``` **Platform and version requirements:** JS (1.1) #### [CanvasCompositing](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-compositing/index.html) ``` interface CanvasCompositing ``` **Platform and version requirements:** JS (1.1) #### [CanvasDirection](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-direction.html) ``` interface CanvasDirection ``` **Platform and version requirements:** JS (1.1) #### [CanvasDrawImage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-draw-image/index.html) ``` interface CanvasDrawImage ``` **Platform and version requirements:** JS (1.1) #### [CanvasDrawPath](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-draw-path/index.html) ``` interface CanvasDrawPath ``` **Platform and version requirements:** JS (1.1) #### [CanvasFillRule](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-fill-rule.html) ``` interface CanvasFillRule ``` **Platform and version requirements:** JS (1.1) #### [CanvasFillStrokeStyles](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-fill-stroke-styles/index.html) ``` interface CanvasFillStrokeStyles ``` **Platform and version requirements:** JS (1.1) #### [CanvasFilters](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-filters/index.html) ``` interface CanvasFilters ``` **Platform and version requirements:** JS (1.1) #### [CanvasGradient](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-gradient/index.html) Exposes the JavaScript [CanvasGradient](https://developer.mozilla.org/en/docs/Web/API/CanvasGradient) to Kotlin ``` abstract class CanvasGradient ``` **Platform and version requirements:** JS (1.1) #### [CanvasHitRegion](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-hit-region/index.html) ``` interface CanvasHitRegion ``` **Platform and version requirements:** JS (1.1) #### [CanvasImageData](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-image-data/index.html) ``` interface CanvasImageData ``` **Platform and version requirements:** JS (1.1) #### [CanvasImageSmoothing](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-image-smoothing/index.html) ``` interface CanvasImageSmoothing ``` **Platform and version requirements:** JS (1.1) #### [CanvasImageSource](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-image-source.html) ``` interface CanvasImageSource : ImageBitmapSource ``` **Platform and version requirements:** JS (1.1) #### [CanvasLineCap](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-line-cap.html) ``` interface CanvasLineCap ``` **Platform and version requirements:** JS (1.1) #### [CanvasLineJoin](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-line-join.html) ``` interface CanvasLineJoin ``` **Platform and version requirements:** JS (1.1) #### [CanvasPath](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-path/index.html) ``` interface CanvasPath ``` **Platform and version requirements:** JS (1.1) #### [CanvasPathDrawingStyles](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-path-drawing-styles/index.html) ``` interface CanvasPathDrawingStyles ``` **Platform and version requirements:** JS (1.1) #### [CanvasPattern](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-pattern/index.html) Exposes the JavaScript [CanvasPattern](https://developer.mozilla.org/en/docs/Web/API/CanvasPattern) to Kotlin ``` abstract class CanvasPattern ``` **Platform and version requirements:** JS (1.1) #### [CanvasRect](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-rect/index.html) ``` interface CanvasRect ``` **Platform and version requirements:** JS (1.1) #### [CanvasRenderingContext2D](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-rendering-context2-d/index.html) Exposes the JavaScript [CanvasRenderingContext2D](https://developer.mozilla.org/en/docs/Web/API/CanvasRenderingContext2D) to Kotlin ``` abstract class CanvasRenderingContext2D :      CanvasState,     CanvasTransform,     CanvasCompositing,     CanvasImageSmoothing,     CanvasFillStrokeStyles,     CanvasShadowStyles,     CanvasFilters,     CanvasRect,     CanvasDrawPath,     CanvasUserInterface,     CanvasText,     CanvasDrawImage,     CanvasHitRegion,     CanvasImageData,     CanvasPathDrawingStyles,     CanvasTextDrawingStyles,     CanvasPath,     RenderingContext ``` **Platform and version requirements:** JS (1.1) #### [CanvasRenderingContext2DSettings](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-rendering-context2-d-settings/index.html) ``` interface CanvasRenderingContext2DSettings ``` **Platform and version requirements:** JS (1.1) #### [CanvasShadowStyles](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-shadow-styles/index.html) ``` interface CanvasShadowStyles ``` **Platform and version requirements:** JS (1.1) #### [CanvasState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-state/index.html) ``` interface CanvasState ``` **Platform and version requirements:** JS (1.1) #### [CanvasText](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-text/index.html) ``` interface CanvasText ``` **Platform and version requirements:** JS (1.1) #### [CanvasTextAlign](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-text-align.html) ``` interface CanvasTextAlign ``` **Platform and version requirements:** JS (1.1) #### [CanvasTextBaseline](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-text-baseline.html) ``` interface CanvasTextBaseline ``` **Platform and version requirements:** JS (1.1) #### [CanvasTextDrawingStyles](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-text-drawing-styles/index.html) ``` interface CanvasTextDrawingStyles ``` **Platform and version requirements:** JS (1.1) #### [CanvasTransform](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-transform/index.html) ``` interface CanvasTransform ``` **Platform and version requirements:** JS (1.1) #### [CanvasUserInterface](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-canvas-user-interface/index.html) ``` interface CanvasUserInterface ``` **Platform and version requirements:** JS (1.1) #### [Capabilities](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-capabilities.html) ``` interface Capabilities ``` **Platform and version requirements:** JS (1.1) #### [CaretPosition](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-caret-position/index.html) Exposes the JavaScript [CaretPosition](https://developer.mozilla.org/en/docs/Web/API/CaretPosition) to Kotlin ``` abstract class CaretPosition ``` **Platform and version requirements:** Native (1.3) #### [CCall](../../kotlinx.cinterop.internal/-c-call/index) ``` annotation class CCall ``` **Platform and version requirements:** Native (1.3) #### [CEnum](../../kotlinx.cinterop/-c-enum/index) ``` interface CEnum ``` **Platform and version requirements:** Native (1.3) #### [CEnumEntryAlias](../../kotlinx.cinterop.internal/-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](../../kotlinx.cinterop.internal/-c-enum-var-type-size/index) Stores instance size of the type T: CEnumVar. ``` annotation class CEnumVarTypeSize ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Char](../-char/index) Represents a 16-bit Unicode character. ``` class Char : Comparable<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharArray](../-char-array/index) An array of chars. When targeting the JVM, instances of this class are represented as `char[]`. ``` class CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CharIterator](../../kotlin.collections/-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) #### [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) #### [CharSequence](../-char-sequence/index) Represents a readable sequence of [Char](../-char/index#kotlin.Char) values. ``` interface CharSequence ``` **Platform and version requirements:** JVM (1.0) #### [Charsets](../../kotlin.text/-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 ``` **Platform and version requirements:** JS (1.1) #### [ChildNode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-child-node/index.html) Exposes the JavaScript [ChildNode](https://developer.mozilla.org/en/docs/Web/API/ChildNode) to Kotlin ``` interface ChildNode ``` **Platform and version requirements:** JS (1.1) #### [Client](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-client/index.html) Exposes the JavaScript [Client](https://developer.mozilla.org/en/docs/Web/API/Client) to Kotlin ``` abstract class Client :      UnionClientOrMessagePortOrServiceWorker ``` **Platform and version requirements:** JS (1.1) #### [ClientQueryOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-client-query-options/index.html) ``` interface ClientQueryOptions ``` **Platform and version requirements:** JS (1.1) #### [Clients](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-clients/index.html) Exposes the JavaScript [Clients](https://developer.mozilla.org/en/docs/Web/API/Clients) to Kotlin ``` abstract class Clients ``` **Platform and version requirements:** JS (1.1) #### [ClientType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-client-type.html) ``` interface ClientType ``` **Platform and version requirements:** JS (1.1) #### [ClipboardEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.clipboard/-clipboard-event-init/index.html) ``` interface ClipboardEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [ClipboardPermissionDescriptor](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.clipboard/-clipboard-permission-descriptor/index.html) ``` interface ClipboardPermissionDescriptor ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ClosedFloatingPointRange](../../kotlin.ranges/-closed-floating-point-range/index) Represents a range of floating point numbers. Extends [ClosedRange](../../kotlin.ranges/-closed-range/index) interface providing custom operation [lessThanOrEquals](../../kotlin.ranges/-closed-floating-point-range/less-than-or-equals) for comparing values of range domain type. ``` interface ClosedFloatingPointRange<T : Comparable<T>> :      ClosedRange<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ClosedRange](../../kotlin.ranges/-closed-range/index) Represents a range of values (for example, numbers or characters) where both the lower and upper bounds are included in the range. See the [Kotlin language documentation](../../../../../../docs/ranges) for more information. ``` interface ClosedRange<T : Comparable<T>> ``` **Platform and version requirements:** JS (1.1) #### [CloseEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-close-event-init/index.html) ``` interface CloseEventInit : EventInit ``` **Platform and version requirements:** Native (1.3) #### [CName](../../kotlin.native/-c-name/index) Makes top level function available from C/C++ code with the given name. ``` annotation class CName ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Collection](../../kotlin.collections/-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](../../kotlin.collections/-mutable-collection/index#kotlin.collections.MutableCollection) interface. ``` interface Collection<out E> : Iterable<E> ``` **Platform and version requirements:** JS (1.1) #### [ColorSpaceConversion](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-color-space-conversion.html) ``` interface ColorSpaceConversion ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Comparable](../-comparable/index) Classes which inherit from this interface have a defined total ordering between their instances. ``` interface Comparable<in T> ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [ComparableTimeMark](../../kotlin.time/-comparable-time-mark/index) A [TimeMark](../../kotlin.time/-time-mark/index) that can be compared for difference with other time marks obtained from the same [TimeSource.WithComparableMarks](../../kotlin.time/-time-source/-with-comparable-marks/index) time source. ``` interface ComparableTimeMark :      TimeMark,     Comparable<ComparableTimeMark> ``` #### [Comparator](../-comparator/index) Provides a comparison function for imposing a total ordering between instances of the type [T](../-comparator/index#T). **Platform and version requirements:** JS (1.1), Native (1.3) ``` fun interface Comparator<T> ``` **Platform and version requirements:** JVM (1.1) ``` typealias Comparator<T> = Comparator<T> ``` **Platform and version requirements:** JS (1.1) #### [CompositionEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-composition-event-init/index.html) ``` interface CompositionEventInit : UIEventInit ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ConditionalEffect](../../kotlin.contracts/-conditional-effect) An effect of some condition being true after observing another effect of a function. ``` interface ConditionalEffect : Effect ``` **Platform and version requirements:** JS (1.1) #### [Console](../../kotlin.js/-console/index) Exposes the [console API](https://developer.mozilla.org/en/DOM/console) to Kotlin. ``` interface Console ``` **Platform and version requirements:** Native (1.3) #### [ConstantValue](../../kotlinx.cinterop.internal/-constant-value/index) Collection of annotations that allow to store constant values. ``` object ConstantValue ``` **Platform and version requirements:** JS (1.1) #### [ConstrainablePattern](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constrainable-pattern/index.html) ``` interface ConstrainablePattern ``` **Platform and version requirements:** JS (1.1) #### [ConstrainBooleanParameters](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constrain-boolean-parameters/index.html) Exposes the JavaScript [ConstrainBooleanParameters](https://developer.mozilla.org/en/docs/Web/API/ConstrainBooleanParameters) to Kotlin ``` interface ConstrainBooleanParameters ``` **Platform and version requirements:** JS (1.1) #### [ConstrainDOMStringParameters](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constrain-d-o-m-string-parameters/index.html) Exposes the JavaScript [ConstrainDOMStringParameters](https://developer.mozilla.org/en/docs/Web/API/ConstrainDOMStringParameters) to Kotlin ``` interface ConstrainDOMStringParameters ``` **Platform and version requirements:** JS (1.1) #### [ConstrainDoubleRange](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constrain-double-range/index.html) ``` interface ConstrainDoubleRange : DoubleRange ``` **Platform and version requirements:** JS (1.1) #### [Constraints](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constraints/index.html) ``` interface Constraints : ConstraintSet ``` **Platform and version requirements:** JS (1.1) #### [ConstraintSet](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constraint-set.html) ``` interface ConstraintSet ``` **Platform and version requirements:** JS (1.1) #### [ConstrainULongRange](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-constrain-u-long-range/index.html) ``` interface ConstrainULongRange : ULongRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ContextFunctionTypeParams](../-context-function-type-params/index) ``` annotation class ContextFunctionTypeParams ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Continuation](../../kotlin.coroutines/-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:** Native (1.3) #### [Continuation0](../../kotlin.native.concurrent/-continuation0/index) ``` class Continuation0 : () -> Unit ``` **Platform and version requirements:** Native (1.3) #### [Continuation1](../../kotlin.native.concurrent/-continuation1/index) ``` class Continuation1<T1> : (T1) -> Unit ``` **Platform and version requirements:** Native (1.3) #### [Continuation2](../../kotlin.native.concurrent/-continuation2/index) ``` class Continuation2<T1, T2> : (T1, T2) -> Unit ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ContinuationInterceptor](../../kotlin.coroutines/-continuation-interceptor/index) Marks coroutine context element that intercepts coroutine continuations. The coroutines framework uses [ContinuationInterceptor.Key](../../kotlin.coroutines/-continuation-interceptor/-key) to retrieve the interceptor and intercepts all coroutine continuations with [interceptContinuation](../../kotlin.coroutines/-continuation-interceptor/intercept-continuation) invocations. ``` interface ContinuationInterceptor : Element ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ContractBuilder](../../kotlin.contracts/-contract-builder/index) Provides a scope, where the functions of the contract DSL, such as [returns](../../kotlin.contracts/-contract-builder/returns), [callsInPlace](../../kotlin.contracts/-contract-builder/calls-in-place), etc., can be used to describe the contract of a function. ``` interface ContractBuilder ``` **Platform and version requirements:** JS (1.1) #### [ConvertCoordinateOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-convert-coordinate-options/index.html) ``` interface ConvertCoordinateOptions ``` **Platform and version requirements:** JVM (1.8), JRE7 (1.8) #### [CopyActionContext](../../kotlin.io.path/-copy-action-context/index) Context for the `copyAction` function passed to [Path.copyToRecursively](../../kotlin.io.path/java.nio.file.-path/copy-to-recursively). ``` interface CopyActionContext ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [CoroutineContext](../../kotlin.coroutines/-coroutine-context/index) Persistent context for the coroutine. It is an indexed set of [Element](../../kotlin.coroutines/-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](../../kotlin.coroutines/-coroutine-context/-key). ``` interface CoroutineContext ``` **Platform and version requirements:** Native (1.3) #### [CPlusPlusClass](../../kotlinx.cinterop/-c-plus-plus-class) ``` interface CPlusPlusClass ``` **Platform and version requirements:** JS (1.1) #### [CSS](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-c-s-s/index.html) Exposes the JavaScript [CSS](https://developer.mozilla.org/en/docs/Web/API/CSS) to Kotlin ``` abstract class CSS ``` **Platform and version requirements:** JS (1.1) #### [CSSBoxType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-c-s-s-box-type.html) ``` interface CSSBoxType ``` **Platform and version requirements:** JS (1.1) #### [CSSRule](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-c-s-s-rule/index.html) Exposes the JavaScript [CSSRule](https://developer.mozilla.org/en/docs/Web/API/CSSRule) to Kotlin ``` abstract class CSSRule ``` **Platform and version requirements:** JS (1.1) #### [CSSRuleList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-c-s-s-rule-list/index.html) Exposes the JavaScript [CSSRuleList](https://developer.mozilla.org/en/docs/Web/API/CSSRuleList) to Kotlin ``` abstract class CSSRuleList : ItemArrayLike<CSSRule> ``` **Platform and version requirements:** JS (1.1) #### [CSSStyleDeclaration](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-c-s-s-style-declaration/index.html) Exposes the JavaScript [CSSStyleDeclaration](https://developer.mozilla.org/en/docs/Web/API/CSSStyleDeclaration) to Kotlin ``` abstract class CSSStyleDeclaration : ItemArrayLike<String> ``` **Platform and version requirements:** Native (1.3) #### [CStruct](../../kotlinx.cinterop.internal/-c-struct/index) ``` annotation class CStruct ``` **Platform and version requirements:** JS (1.1) #### [CustomElementRegistry](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-custom-element-registry/index.html) Exposes the JavaScript [CustomElementRegistry](https://developer.mozilla.org/en/docs/Web/API/CustomElementRegistry) to Kotlin ``` abstract class CustomElementRegistry ``` **Platform and version requirements:** JS (1.1) #### [CustomEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-custom-event-init/index.html) ``` interface CustomEventInit : EventInit ``` **Platform and version requirements:** Native (1.3) #### [CValuesRef](../../kotlinx.cinterop/-c-values-ref/index) Represents a reference to (possibly empty) sequence of C values. It can be either a stable pointer [CPointer](../../kotlinx.cinterop/-c-pointer/index) or a sequence of immutable values [CValues](../../kotlinx.cinterop/-c-values/index). ``` abstract class CValuesRef<T : CPointed> ``` **Platform and version requirements:** JS (1.1) #### [DataTransfer](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-data-transfer/index.html) Exposes the JavaScript [DataTransfer](https://developer.mozilla.org/en/docs/Web/API/DataTransfer) to Kotlin ``` abstract class DataTransfer ``` **Platform and version requirements:** JS (1.1) #### [DataTransferItem](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-data-transfer-item/index.html) Exposes the JavaScript [DataTransferItem](https://developer.mozilla.org/en/docs/Web/API/DataTransferItem) to Kotlin ``` abstract class DataTransferItem ``` **Platform and version requirements:** JS (1.1) #### [DataTransferItemList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-data-transfer-item-list/index.html) Exposes the JavaScript [DataTransferItemList](https://developer.mozilla.org/en/docs/Web/API/DataTransferItemList) to Kotlin ``` abstract class DataTransferItemList ``` **Platform and version requirements:** JS (1.1) #### [DataView](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-data-view/index.html) Exposes the JavaScript [DataView](https://developer.mozilla.org/en/docs/Web/API/DataView) to Kotlin ``` open class DataView : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Date](../../kotlin.js/-date/index) Exposes the [Date API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date) to Kotlin. ``` class Date ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [DeepRecursiveFunction](../-deep-recursive-function/index) Defines deep recursive function that keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack. To initiate a call to this deep recursive function use its [invoke](../invoke) function. As a rule of thumb, it should be used if recursion goes deeper than a thousand calls. ``` class DeepRecursiveFunction<T, R> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [DeepRecursiveScope](../-deep-recursive-scope/index) A scope class for [DeepRecursiveFunction](../-deep-recursive-function/index) function declaration that defines [callRecursive](../-deep-recursive-scope/call-recursive) methods to recursively call this function or another [DeepRecursiveFunction](../-deep-recursive-function/index) putting the call activation frame on the heap. ``` sealed class DeepRecursiveScope<T, R> ``` **Platform and version requirements:** Native (1.3) #### [DeferScope](../../kotlinx.cinterop/-defer-scope/index) ``` open class DeferScope ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Delegates](../../kotlin.properties/-delegates/index) Standard property delegates. ``` object Delegates ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Deprecated](../-deprecated/index) Marks the annotated declaration as deprecated. ``` annotation class Deprecated ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [DeprecatedSinceKotlin](../-deprecated-since-kotlin/index) Marks the annotated declaration as deprecated. In contrast to [Deprecated](../-deprecated/index#kotlin.Deprecated), severity of the reported diagnostic is not a constant value, but differs depending on the API version of the usage (the value of the `-api-version` argument when compiling the module where the usage is located). If the API version is greater or equal than [hiddenSince](../-deprecated-since-kotlin/hidden-since#kotlin.DeprecatedSinceKotlin%24hiddenSince), the declaration will not be accessible from the code (as if it was deprecated with level [DeprecationLevel.HIDDEN](../-deprecation-level/-h-i-d-d-e-n#kotlin.DeprecationLevel.HIDDEN)), otherwise if the API version is greater or equal than [errorSince](../-deprecated-since-kotlin/error-since#kotlin.DeprecatedSinceKotlin%24errorSince), the usage will be marked as an error (as with [DeprecationLevel.ERROR](../-deprecation-level/-e-r-r-o-r#kotlin.DeprecationLevel.ERROR)), otherwise if the API version is greater or equal than [warningSince](../-deprecated-since-kotlin/warning-since#kotlin.DeprecatedSinceKotlin%24warningSince), the usage will be marked as a warning (as with [DeprecationLevel.WARNING](../-deprecation-level/-w-a-r-n-i-n-g#kotlin.DeprecationLevel.WARNING)), otherwise the annotation is ignored. ``` annotation class DeprecatedSinceKotlin ``` **Platform and version requirements:** Native (1.3) #### [DetachedObjectGraph](../../kotlin.native.concurrent/-detached-object-graph/index) Detached object graph encapsulates transferrable detached subgraph which cannot be accessed externally, until it is attached with the [attach](../../kotlin.native.concurrent/attach) extension function. ``` class DetachedObjectGraph<T> ``` **Platform and version requirements:** JS (1.1) #### [DocumentAndElementEventHandlers](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-document-and-element-event-handlers/index.html) ``` interface DocumentAndElementEventHandlers ``` **Platform and version requirements:** JS (1.1) #### [DocumentOrShadowRoot](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-document-or-shadow-root/index.html) Exposes the JavaScript [DocumentOrShadowRoot](https://developer.mozilla.org/en/docs/Web/API/DocumentOrShadowRoot) to Kotlin ``` interface DocumentOrShadowRoot ``` **Platform and version requirements:** JS (1.1) #### [DocumentReadyState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-document-ready-state.html) ``` interface DocumentReadyState ``` **Platform and version requirements:** JS (1.1) #### [DOMImplementation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-implementation/index.html) Exposes the JavaScript [DOMImplementation](https://developer.mozilla.org/en/docs/Web/API/DOMImplementation) to Kotlin ``` abstract class DOMImplementation ``` **Platform and version requirements:** JS (1.1) #### [DOMMatrixReadOnly](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-matrix-read-only/index.html) Exposes the JavaScript [DOMMatrixReadOnly](https://developer.mozilla.org/en/docs/Web/API/DOMMatrixReadOnly) to Kotlin ``` open class DOMMatrixReadOnly ``` **Platform and version requirements:** JS (1.1) #### [DOMParser](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.parsing/-d-o-m-parser/index.html) Exposes the JavaScript [DOMParser](https://developer.mozilla.org/en/docs/Web/API/DOMParser) to Kotlin ``` open class DOMParser ``` **Platform and version requirements:** JS (1.1) #### [DOMPointInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-point-init/index.html) Exposes the JavaScript [DOMPointInit](https://developer.mozilla.org/en/docs/Web/API/DOMPointInit) to Kotlin ``` interface DOMPointInit ``` **Platform and version requirements:** JS (1.1) #### [DOMPointReadOnly](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-point-read-only/index.html) Exposes the JavaScript [DOMPointReadOnly](https://developer.mozilla.org/en/docs/Web/API/DOMPointReadOnly) to Kotlin ``` open class DOMPointReadOnly ``` **Platform and version requirements:** JS (1.1) #### [DOMQuad](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-quad/index.html) Exposes the JavaScript [DOMQuad](https://developer.mozilla.org/en/docs/Web/API/DOMQuad) to Kotlin ``` open class DOMQuad ``` **Platform and version requirements:** JS (1.1) #### [DOMRectInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-rect-init/index.html) ``` interface DOMRectInit ``` **Platform and version requirements:** JS (1.1) #### [DOMRectList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-rect-list/index.html) ``` interface DOMRectList : ItemArrayLike<DOMRect> ``` **Platform and version requirements:** JS (1.1) #### [DOMRectReadOnly](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-rect-read-only/index.html) Exposes the JavaScript [DOMRectReadOnly](https://developer.mozilla.org/en/docs/Web/API/DOMRectReadOnly) to Kotlin ``` open class DOMRectReadOnly ``` **Platform and version requirements:** JS (1.1) #### [DOMStringMap](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-string-map/index.html) Exposes the JavaScript [DOMStringMap](https://developer.mozilla.org/en/docs/Web/API/DOMStringMap) to Kotlin ``` abstract class DOMStringMap ``` **Platform and version requirements:** JS (1.1) #### [DOMTokenList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-d-o-m-token-list/index.html) Exposes the JavaScript [DOMTokenList](https://developer.mozilla.org/en/docs/Web/API/DOMTokenList) to Kotlin ``` abstract class DOMTokenList : ItemArrayLike<String> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DoubleArray](../-double-array/index) An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`. ``` class DoubleArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [DoubleIterator](../../kotlin.collections/-double-iterator/index) An iterator over a sequence of values of type `Double`. ``` abstract class DoubleIterator : Iterator<Double> ``` **Platform and version requirements:** JS (1.1) #### [DoubleRange](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-double-range/index.html) Exposes the JavaScript [DoubleRange](https://developer.mozilla.org/en/docs/Web/API/DoubleRange) to Kotlin ``` interface DoubleRange ``` **Platform and version requirements:** JS (1.1) #### [DragEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-drag-event-init/index.html) ``` interface DragEventInit : MouseEventInit ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [DslMarker](../-dsl-marker/index) When applied to annotation class X specifies that X defines a DSL language ``` annotation class DslMarker ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [Duration](../../kotlin.time/-duration/index) Represents the amount of time one instant of time is away from another instant. ``` class Duration : Comparable<Duration> ``` **Platform and version requirements:** JS (1.6) #### [EagerInitialization](../../kotlin.js/-eager-initialization/index) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. ``` annotation class EagerInitialization ``` **Platform and version requirements:** Native (1.3) #### [EagerInitialization](../../kotlin.native/-eager-initialization/index) Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property. This annotation can be used as temporal migration assistance during the transition from the previous Kotlin/Native initialization scheme "eager by default" to the new one, "lazy by default". ``` annotation class EagerInitialization ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Effect](../../kotlin.contracts/-effect) Represents an effect of a function invocation, either directly observable, such as the function returning normally, or a side-effect, such as the function's lambda parameter being called in place. ``` interface Effect ``` **Platform and version requirements:** JS (1.1) #### [ElementContentEditable](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-element-content-editable/index.html) ``` interface ElementContentEditable ``` **Platform and version requirements:** JS (1.1) #### [ElementCreationOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-element-creation-options/index.html) ``` interface ElementCreationOptions ``` **Platform and version requirements:** JS (1.1) #### [ElementCSSInlineStyle](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-element-c-s-s-inline-style/index.html) ``` interface ElementCSSInlineStyle ``` **Platform and version requirements:** JS (1.1) #### [ElementDefinitionOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-element-definition-options/index.html) ``` interface ElementDefinitionOptions ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [EmptyCoroutineContext](../../kotlin.coroutines/-empty-coroutine-context/index) An empty coroutine context. ``` object EmptyCoroutineContext : CoroutineContext, Serializable ``` **Platform and version requirements:** JS (1.1) #### [EndOfStreamError](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediasource/-end-of-stream-error.html) ``` interface EndOfStreamError ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Entry](../../kotlin.collections/-map/-entry/index) Represents a key/value pair held by a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map). ``` interface Entry<out K, out V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Enum](../-enum/index) The common base class of all enum classes. See the [Kotlin language documentation](../../../../../../docs/enum-classes) for more information on enum classes. ``` abstract class Enum<E : Enum<E>> : Comparable<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](../../kotlin.collections/-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](../-enum/ordinal#kotlin.Enum%24ordinal) values. ``` sealed interface EnumEntries<E : Enum<E>> : List<E> ``` **Platform and version requirements:** JS (1.1) #### [ErrorEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-error-event-init/index.html) ``` interface ErrorEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [Event](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-event/index.html) Exposes the JavaScript [Event](https://developer.mozilla.org/en/docs/Web/API/Event) to Kotlin ``` open class Event ``` **Platform and version requirements:** JS (1.1) #### [EventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-event-init/index.html) ``` interface EventInit ``` **Platform and version requirements:** JS (1.1) #### [EventListener](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-event-listener/index.html) Exposes the JavaScript [EventListener](https://developer.mozilla.org/en/docs/Web/API/EventListener) to Kotlin ``` interface EventListener ``` **Platform and version requirements:** JS (1.1) #### [EventListenerOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-event-listener-options/index.html) ``` interface EventListenerOptions ``` **Platform and version requirements:** JS (1.1) #### [EventModifierInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-event-modifier-init/index.html) ``` interface EventModifierInit : UIEventInit ``` **Platform and version requirements:** JS (1.1) #### [EventSourceInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-event-source-init/index.html) ``` interface EventSourceInit ``` **Platform and version requirements:** JS (1.1) #### [EventTarget](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-event-target/index.html) Exposes the JavaScript [EventTarget](https://developer.mozilla.org/en/docs/Web/API/EventTarget) to Kotlin ``` abstract class EventTarget ``` **Platform and version requirements:** JS (1.1), Native (1.1) #### [ExperimentalAssociatedObjects](../../kotlin.reflect/-experimental-associated-objects/index) The experimental marker for associated objects API. ``` annotation class ExperimentalAssociatedObjects ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalContracts](../../kotlin.contracts/-experimental-contracts/index) This marker distinguishes the experimental contract declaration API and is used to opt-in for that feature when declaring contracts of user functions. ``` annotation class ExperimentalContracts ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [ExperimentalJsExport](../../kotlin.js/-experimental-js-export/index) Marks experimental JS export annotations. ``` annotation class ExperimentalJsExport ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalMultiplatform](../-experimental-multiplatform/index) The experimental multiplatform support API marker. ``` annotation class ExperimentalMultiplatform ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalObjCName](../../kotlin.experimental/-experimental-obj-c-name/index) This annotation marks the experimental [ObjCName](../../kotlin.native/-obj-c-name/index#kotlin.native.ObjCName) annotation. ``` annotation class ExperimentalObjCName ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalObjCRefinement](../../kotlin.experimental/-experimental-obj-c-refinement/index) This annotation marks the experimental Objective-C export refinement annotations. ``` annotation class ExperimentalObjCRefinement ``` **Platform and version requirements:** JVM (1.4), JRE7 (1.4) #### [ExperimentalPathApi](../../kotlin.io.path/-experimental-path-api/index) This annotation marks the extensions and top-level functions for working with [java.nio.file.Path](https://docs.oracle.com/javase/8/docs/api/java/nio/file/Path.html) considered experimental. ``` annotation class ExperimentalPathApi ``` **Platform and version requirements:** JVM (1.5) #### [ExperimentalReflectionOnLambdas](../../kotlin.reflect.jvm/-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 ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalStdlibApi](../-experimental-stdlib-api/index) This annotation marks the standard library API that is considered experimental and is not subject to the [general compatibility guarantees](../../../../../../docs/evolution/components-stability) given for the standard library: the behavior of such API may be changed or the API may be removed completely in any further release. ``` annotation class ExperimentalStdlibApi ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [ExperimentalSubclassOptIn](../-experimental-subclass-opt-in/index) This annotation marks the experimental preview of the language feature [SubclassOptInRequired](../-subclass-opt-in-required/index). ``` annotation class ExperimentalSubclassOptIn ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalTime](../../kotlin.time/-experimental-time/index) This annotation marks the experimental preview of the standard library API for measuring time and working with durations. ``` annotation class ExperimentalTime ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ExperimentalTypeInference](../../kotlin.experimental/-experimental-type-inference/index) The experimental marker for type inference augmenting annotations. ``` annotation class ExperimentalTypeInference ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExperimentalUnsignedTypes](../-experimental-unsigned-types/index) Marks the API that is dependent on the experimental unsigned types, including those types themselves. ``` annotation class ExperimentalUnsignedTypes ``` **Platform and version requirements:** Native (1.3) #### [ExportObjCClass](../../kotlinx.cinterop/-export-obj-c-class/index) Makes Kotlin subclass of Objective-C class visible for runtime lookup after Kotlin `main` function gets invoked. ``` annotation class ExportObjCClass ``` **Platform and version requirements:** JS (1.1) #### [ExtendableEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-extendable-event-init.html) ``` interface ExtendableEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [ExtendableMessageEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-extendable-message-event-init/index.html) ``` interface ExtendableMessageEventInit : ExtendableEventInit ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ExtensionFunctionType](../-extension-function-type/index) Signifies that the annotated functional type represents an extension function. ``` annotation class ExtensionFunctionType ``` **Platform and version requirements:** JS (1.1) #### [External](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-external/index.html) ``` interface External ``` **Platform and version requirements:** Native (1.3) #### [ExternalObjCClass](../../kotlinx.cinterop/-external-obj-c-class/index) ``` annotation class ExternalObjCClass ``` **Platform and version requirements:** JS (1.1) #### [FetchEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-fetch-event-init/index.html) ``` interface FetchEventInit : ExtendableEventInit ``` **Platform and version requirements:** JS (1.1) #### [FileList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-file-list/index.html) Exposes the JavaScript [FileList](https://developer.mozilla.org/en/docs/Web/API/FileList) to Kotlin ``` abstract class FileList : ItemArrayLike<File> ``` **Platform and version requirements:** JS (1.1) #### [FilePropertyBag](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-file-property-bag/index.html) ``` interface FilePropertyBag : BlobPropertyBag ``` **Platform and version requirements:** JS (1.1) #### [FileReaderSync](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.files/-file-reader-sync/index.html) Exposes the JavaScript [FileReaderSync](https://developer.mozilla.org/en/docs/Web/API/FileReaderSync) to Kotlin ``` open class FileReaderSync ``` **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> ``` **Platform and version requirements:** JVM (1.7), JRE7 (1.7) #### [FileVisitorBuilder](../../kotlin.io.path/-file-visitor-builder/index) The builder to provide implementation of the file visitor that [fileVisitor](../../kotlin.io.path/file-visitor) builds. ``` sealed interface FileVisitorBuilder ``` **Platform and version requirements:** JS (1.1) #### [Float32Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-float32-array/index.html) Exposes the JavaScript [Float32Array](https://developer.mozilla.org/en/docs/Web/API/Float32Array) to Kotlin ``` open class Float32Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Float64Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-float64-array/index.html) Exposes the JavaScript [Float64Array](https://developer.mozilla.org/en/docs/Web/API/Float64Array) to Kotlin ``` open class Float64Array : ArrayBufferView ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FloatArray](../-float-array/index) An array of floats. When targeting the JVM, instances of this class are represented as `float[]`. ``` class FloatArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [FloatIterator](../../kotlin.collections/-float-iterator/index) An iterator over a sequence of values of type `Float`. ``` abstract class FloatIterator : Iterator<Float> ``` **Platform and version requirements:** JS (1.1) #### [FocusEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-focus-event-init/index.html) ``` interface FocusEventInit : UIEventInit ``` **Platform and version requirements:** JS (1.1) #### [ForeignFetchEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-foreign-fetch-event-init/index.html) ``` interface ForeignFetchEventInit : ExtendableEventInit ``` **Platform and version requirements:** JS (1.1) #### [ForeignFetchOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-foreign-fetch-options/index.html) ``` interface ForeignFetchOptions ``` **Platform and version requirements:** JS (1.1) #### [ForeignFetchResponse](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-foreign-fetch-response/index.html) ``` interface ForeignFetchResponse ``` **Platform and version requirements:** JS (1.1) #### [FormData](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.xhr/-form-data/index.html) Exposes the JavaScript [FormData](https://developer.mozilla.org/en/docs/Web/API/FormData) to Kotlin ``` open class FormData ``` **Platform and version requirements:** JS (1.1) #### [FrameType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-frame-type.html) ``` interface FrameType ``` **Platform and version requirements:** Native (1.3) #### [FreezableAtomicReference](../../kotlin.native.concurrent/-freezable-atomic-reference/index) Note: this class is useful only with legacy memory manager. Please use [AtomicReference](../../kotlin.native.concurrent/-atomic-reference/index) instead. ``` class FreezableAtomicReference<T> ``` **Platform and version requirements:** #### [FreezingIsDeprecated](../../kotlin.native/-freezing-is-deprecated) Freezing API is deprecated since 1.7.20. ``` annotation class FreezingIsDeprecated ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Function](../-function) Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. ``` interface Function<out R> ``` **Platform and version requirements:** Native (1.3) #### [Future](../../kotlin.native.concurrent/-future/index) ``` class Future<T> ``` **Platform and version requirements:** JS (1.1) #### [GeometryUtils](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-geometry-utils/index.html) Exposes the JavaScript [GeometryUtils](https://developer.mozilla.org/en/docs/Web/API/GeometryUtils) to Kotlin ``` interface GeometryUtils ``` **Platform and version requirements:** JS (1.1) #### [GetNotificationOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-get-notification-options/index.html) ``` interface GetNotificationOptions ``` **Platform and version requirements:** JS (1.1) #### [GetRootNodeOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-get-root-node-options/index.html) ``` interface GetRootNodeOptions ``` **Platform and version requirements:** JS (1.1) #### [GetSVGDocument](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-get-s-v-g-document/index.html) ``` interface GetSVGDocument ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../../kotlin.reflect/-k-property/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Accessor<V>, KFunction<V> ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../../kotlin.reflect/-k-property0/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<out V> : KProperty.Getter<V>, () -> V ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../../kotlin.reflect/-k-property1/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<T, out V> : KProperty.Getter<V>, (T) -> V ``` **Platform and version requirements:** JVM (1.0) #### [Getter](../../kotlin.reflect/-k-property2/-getter) Getter of the property is a `get` method declared alongside the property. ``` interface Getter<D, E, out V> :      KProperty.Getter<V>,     (D, E) -> V ``` **Platform and version requirements:** JS (1.1) #### [GlobalEventHandlers](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-global-event-handlers/index.html) Exposes the JavaScript [GlobalEventHandlers](https://developer.mozilla.org/en/docs/Web/API/GlobalEventHandlers) to Kotlin ``` interface GlobalEventHandlers ``` **Platform and version requirements:** JS (1.1) #### [GlobalPerformance](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.performance/-global-performance/index.html) ``` interface GlobalPerformance ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [Grouping](../../kotlin.collections/-grouping/index) Represents a source of elements with a [keyOf](../../kotlin.collections/-grouping/key-of) function, which can be applied to each element to get its key. ``` interface Grouping<T, out K> ``` **Platform and version requirements:** JS (1.1) #### [HashChangeEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-hash-change-event-init/index.html) ``` interface HashChangeEventInit : EventInit ``` #### [HashMap](../../kotlin.collections/-hash-map/index) Hash table based implementation of the [MutableMap](../../kotlin.collections/-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](../../kotlin.collections/-hash-set/index) The implementation of the [MutableSet](../../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [HashMap](../../kotlin.collections/-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:** JS (1.1) #### [Headers](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-headers/index.html) Exposes the JavaScript [Headers](https://developer.mozilla.org/en/docs/Web/API/Headers) to Kotlin ``` open class Headers ``` **Platform and version requirements:** Native (1.0) #### [HiddenFromObjC](../../kotlin.native/-hidden-from-obj-c/index) Instructs the Kotlin compiler to remove this function or property from the public Objective-C API. ``` annotation class HiddenFromObjC ``` **Platform and version requirements:** Native (1.0) #### [HidesFromObjC](../../kotlin.native/-hides-from-obj-c/index) Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API. ``` annotation class HidesFromObjC ``` **Platform and version requirements:** JS (1.1) #### [History](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-history/index.html) Exposes the JavaScript [History](https://developer.mozilla.org/en/docs/Web/API/History) to Kotlin ``` abstract class History ``` **Platform and version requirements:** JS (1.1) #### [HitRegionOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-hit-region-options/index.html) ``` interface HitRegionOptions ``` **Platform and version requirements:** JS (1.1) #### [HTMLAllCollection](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-h-t-m-l-all-collection/index.html) ``` abstract class HTMLAllCollection ``` **Platform and version requirements:** JS (1.1) #### [HTMLCollection](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-h-t-m-l-collection/index.html) Exposes the JavaScript [HTMLCollection](https://developer.mozilla.org/en/docs/Web/API/HTMLCollection) to Kotlin ``` abstract class HTMLCollection :      ItemArrayLike<Element>,     UnionElementOrHTMLCollection ``` **Platform and version requirements:** JS (1.1) #### [HTMLHyperlinkElementUtils](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-h-t-m-l-hyperlink-element-utils/index.html) Exposes the JavaScript [HTMLHyperlinkElementUtils](https://developer.mozilla.org/en/docs/Web/API/HTMLHyperlinkElementUtils) to Kotlin ``` interface HTMLHyperlinkElementUtils ``` **Platform and version requirements:** JS (1.1) #### [HTMLOrSVGImageElement](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-h-t-m-l-or-s-v-g-image-element.html) ``` interface HTMLOrSVGImageElement : CanvasImageSource ``` **Platform and version requirements:** JS (1.1) #### [HTMLOrSVGScriptElement](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-h-t-m-l-or-s-v-g-script-element.html) ``` interface HTMLOrSVGScriptElement ``` **Platform and version requirements:** JS (1.1) #### [ImageBitmap](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-bitmap/index.html) Exposes the JavaScript [ImageBitmap](https://developer.mozilla.org/en/docs/Web/API/ImageBitmap) to Kotlin ``` abstract class ImageBitmap :      CanvasImageSource,     TexImageSource ``` **Platform and version requirements:** JS (1.1) #### [ImageBitmapOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-bitmap-options/index.html) ``` interface ImageBitmapOptions ``` **Platform and version requirements:** JS (1.1) #### [ImageBitmapRenderingContext](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-bitmap-rendering-context/index.html) Exposes the JavaScript [ImageBitmapRenderingContext](https://developer.mozilla.org/en/docs/Web/API/ImageBitmapRenderingContext) to Kotlin ``` abstract class ImageBitmapRenderingContext ``` **Platform and version requirements:** JS (1.1) #### [ImageBitmapRenderingContextSettings](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-bitmap-rendering-context-settings/index.html) ``` interface ImageBitmapRenderingContextSettings ``` **Platform and version requirements:** JS (1.1) #### [ImageBitmapSource](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-bitmap-source.html) ``` interface ImageBitmapSource ``` **Platform and version requirements:** JS (1.1) #### [ImageData](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-data/index.html) Exposes the JavaScript [ImageData](https://developer.mozilla.org/en/docs/Web/API/ImageData) to Kotlin ``` open class ImageData : ImageBitmapSource, TexImageSource ``` **Platform and version requirements:** JS (1.1) #### [ImageOrientation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-orientation.html) ``` interface ImageOrientation ``` **Platform and version requirements:** JS (1.1) #### [ImageSmoothingQuality](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-image-smoothing-quality.html) ``` interface ImageSmoothingQuality ``` **Platform and version requirements:** Native (1.3) #### [ImmutableBlob](../../kotlin.native/-immutable-blob/index) An immutable compile-time array of bytes. ``` class ImmutableBlob ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IndexedValue](../../kotlin.collections/-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:** JS (1.1) #### [InputEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-input-event-init/index.html) ``` interface InputEventInit : UIEventInit ``` **Platform and version requirements:** JS (1.1) #### [Int16Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-int16-array/index.html) Exposes the JavaScript [Int16Array](https://developer.mozilla.org/en/docs/Web/API/Int16Array) to Kotlin ``` open class Int16Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Int32Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-int32-array/index.html) Exposes the JavaScript [Int32Array](https://developer.mozilla.org/en/docs/Web/API/Int32Array) to Kotlin ``` open class Int32Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Int8Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-int8-array/index.html) Exposes the JavaScript [Int8Array](https://developer.mozilla.org/en/docs/Web/API/Int8Array) to Kotlin ``` open class Int8Array : ArrayBufferView ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntArray](../-int-array/index) An array of ints. When targeting the JVM, instances of this class are represented as `int[]`. ``` class IntArray ``` **Platform and version requirements:** Native (1.3) #### [InteropStubs](../../kotlinx.cinterop/-interop-stubs/index) ``` annotation class InteropStubs ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [IntIterator](../../kotlin.collections/-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) #### [IntProgression](../../kotlin.ranges/-int-progression/index) A progression of values of type `Int`. ``` open class IntProgression : Iterable<Int> ``` **Platform and version requirements:** Native (1.7) #### [IntrinsicConstEvaluation](../../kotlin.internal/-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 ``` **Platform and version requirements:** JS (1.1) #### [ItemArrayLike](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-item-array-like/index.html) ``` interface ItemArrayLike<out T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Iterable](../../kotlin.collections/-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](../../kotlin.collections/-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> ``` **Platform and version requirements:** JS (1.1) #### [JsClass](../../kotlin.js/-js-class/index) Represents the constructor of a class. Instances of `JsClass` can be passed to JavaScript APIs that expect a constructor reference. ``` interface JsClass<T : Any> ``` **Platform and version requirements:** JS (1.3) #### [JsExport](../../kotlin.js/-js-export/index) Exports top-level declaration on JS platform. ``` annotation class JsExport ``` **Platform and version requirements:** JS (1.1) #### [JsModule](../../kotlin.js/-js-module/index) Denotes an `external` declaration that must be imported from native JavaScript library. ``` annotation class JsModule ``` **Platform and version requirements:** JS (1.0) #### [JsName](../../kotlin.js/-js-name/index) Gives a declaration (a function, a property or a class) specific name in JavaScript. ``` annotation class JsName ``` **Platform and version requirements:** JS (1.1) #### [JsNonModule](../../kotlin.js/-js-non-module/index) Denotes an `external` declaration that can be used without module system. ``` annotation class JsNonModule ``` **Platform and version requirements:** JS (1.1) #### [Json](../../kotlin.js/-json/index) An interface for indexing access to a collection of key-value pairs, where type of key is String and type of value is Any?. ``` interface Json ``` **Platform and version requirements:** JS (1.1) #### [JSON](../../kotlin.js/-j-s-o-n/index) Exposes the JavaScript [JSON object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON) to Kotlin. ``` object JSON ``` **Platform and version requirements:** JS (1.1) #### [JsQualifier](../../kotlin.js/-js-qualifier/index) Adds prefix to `external` declarations in a source file. ``` annotation class JsQualifier ``` **Platform and version requirements:** Native (1.3) #### [JsValue](../../kotlinx.wasm.jsinterop/-js-value/index) ``` open class JsValue ``` **Platform and version requirements:** JVM (1.2) #### [JvmDefault](../../kotlin.jvm/-jvm-default/index) Specifies that a JVM default method should be generated for non-abstract Kotlin interface member. ``` annotation class JvmDefault ``` **Platform and version requirements:** JVM (1.6) #### [JvmDefaultWithCompatibility](../../kotlin.jvm/-jvm-default-with-compatibility/index) Forces the compiler to generate compatibility accessors for the annotated interface in the `DefaultImpls` class. Please note that if an interface is annotated with this annotation for binary compatibility, public derived Kotlin interfaces should also be annotated with it, because their `DefaultImpls` methods will be used to access implementations from the `DefaultImpls` class of the original interface. ``` annotation class JvmDefaultWithCompatibility ``` **Platform and version requirements:** JVM (1.4) #### [JvmDefaultWithoutCompatibility](../../kotlin.jvm/-jvm-default-without-compatibility/index) Prevents the compiler from generating compatibility accessors for the annotated class or interface, and suppresses any related compatibility warnings. In other words, this annotation makes the compiler generate the annotated class or interface in the `-Xjvm-default=all` mode, where only JVM default methods are generated, without `DefaultImpls`. ``` annotation class JvmDefaultWithoutCompatibility ``` **Platform and version requirements:** JVM (1.0) #### [JvmField](../../kotlin.jvm/-jvm-field/index) Instructs the Kotlin compiler not to generate getters/setters for this property and expose it as a field. ``` annotation class JvmField ``` **Platform and version requirements:** JVM (1.5) #### [JvmInline](../../kotlin.jvm/-jvm-inline/index) Specifies that given value class is inline class. ``` annotation class JvmInline ``` **Platform and version requirements:** JVM (1.0) #### [JvmMultifileClass](../../kotlin.jvm/-jvm-multifile-class/index) Instructs the Kotlin compiler to generate a multifile class with top-level functions and properties declared in this file as one of its parts. Name of the corresponding multifile class is provided by the [JvmName](../../kotlin.jvm/-jvm-name/index#kotlin.jvm.JvmName) annotation. ``` annotation class JvmMultifileClass ``` **Platform and version requirements:** JVM (1.0) #### [JvmName](../../kotlin.jvm/-jvm-name/index) Specifies the name for the Java class or method which is generated from this element. ``` annotation class JvmName ``` **Platform and version requirements:** JVM (1.0) #### [JvmOverloads](../../kotlin.jvm/-jvm-overloads/index) Instructs the Kotlin compiler to generate overloads for this function that substitute default parameter values. ``` annotation class JvmOverloads ``` **Platform and version requirements:** JVM (1.5) #### [JvmRecord](../../kotlin.jvm/-jvm-record/index) Instructs compiler to mark the class as a record and generate relevant toString/equals/hashCode methods ``` annotation class JvmRecord ``` **Platform and version requirements:** JVM (1.8) #### [JvmSerializableLambda](../../kotlin.jvm/-jvm-serializable-lambda/index) Makes the annotated lambda function implement `java.io.Serializable`, generates a pretty `toString` implementation and adds reflection metadata. ``` annotation class JvmSerializableLambda ``` **Platform and version requirements:** JVM (1.0) #### [JvmStatic](../../kotlin.jvm/-jvm-static/index) Specifies that an additional static method needs to be generated from this element if it's a function. If this element is a property, additional static getter/setter methods should be generated. ``` annotation class JvmStatic ``` **Platform and version requirements:** JVM (1.0) #### [JvmSuppressWildcards](../../kotlin.jvm/-jvm-suppress-wildcards/index) Instructs compiler to generate or omit wildcards for type arguments corresponding to parameters with declaration-site variance, for example such as `Collection<out T>` has. ``` annotation class JvmSuppressWildcards ``` **Platform and version requirements:** JVM (1.0) #### [JvmSynthetic](../../kotlin.jvm/-jvm-synthetic/index) Sets `ACC_SYNTHETIC` flag on the annotated target in the Java bytecode. ``` annotation class JvmSynthetic ``` **Platform and version requirements:** JVM (1.0) #### [JvmWildcard](../../kotlin.jvm/-jvm-wildcard/index) Instructs compiler to generate wildcard for annotated type arguments corresponding to parameters with declaration-site variance. ``` annotation class JvmWildcard ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [KAnnotatedElement](../../kotlin.reflect/-k-annotated-element/index) Represents an annotated element and allows to obtain its annotations. See the [Kotlin language documentation](../../../../../../docs/annotations) for more information. ``` interface KAnnotatedElement ``` #### [KCallable](../../kotlin.reflect/-k-callable/index) Represents a callable entity, such as a function or a property. **Platform and version requirements:** JS (1.1) ``` interface KCallable<out R> ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KCallable<out R> : KAnnotatedElement ``` #### [KClass](../../kotlin.reflect/-k-class/index) Represents a class and provides introspection capabilities. Instances of this class are obtainable by the `::class` syntax. See the [Kotlin language documentation](../../../../../../docs/reflection#class-references) for more information. **Platform and version requirements:** JS (1.1) ``` interface KClass<T : Any> : KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.3) ``` interface KClass<T : Any> :      KDeclarationContainer,     KAnnotatedElement,     KClassifier ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KClassifier](../../kotlin.reflect/-k-classifier) A classifier is either a class or a type parameter. ``` interface KClassifier ``` **Platform and version requirements:** JVM (1.0), Native (1.0) #### [KDeclarationContainer](../../kotlin.reflect/-k-declaration-container/index) Represents an entity which may contain declarations of any other entities, such as a class or a package. ``` interface KDeclarationContainer ``` **Platform and version requirements:** JS (1.1) #### [KeyboardEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-keyboard-event-init/index.html) ``` interface KeyboardEventInit : EventModifierInit ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KFunction](../../kotlin.reflect/-k-function/index) Represents a function with introspection capabilities. ``` interface KFunction<out R> : KCallable<R>, Function<R> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty](../../kotlin.reflect/-k-mutable-property/index) Represents a property declared as a `var`. ``` interface KMutableProperty<V> : KProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty0](../../kotlin.reflect/-k-mutable-property0/index) Represents a `var`-property without any kind of receiver. ``` interface KMutableProperty0<V> :      KProperty0<V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty1](../../kotlin.reflect/-k-mutable-property1/index) Represents a `var`-property, operations on which take one receiver as a parameter. ``` interface KMutableProperty1<T, V> :      KProperty1<T, V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KMutableProperty2](../../kotlin.reflect/-k-mutable-property2/index) Represents a `var`-property, operations on which take two receivers as parameters. ``` interface KMutableProperty2<D, E, V> :      KProperty2<D, E, V>,     KMutableProperty<V> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KotlinVersion](../-kotlin-version/index) Represents a version of the Kotlin standard library. ``` class KotlinVersion : Comparable<KotlinVersion> ``` **Platform and version requirements:** JVM (1.0) #### [KParameter](../../kotlin.reflect/-k-parameter/index) Represents a parameter passed to a function or a property getter/setter, including `this` and extension receiver parameters. ``` interface KParameter : KAnnotatedElement ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty](../../kotlin.reflect/-k-property/index) Represents a property, such as a named `val` or `var` declaration. Instances of this class are obtainable by the `::` operator. ``` interface KProperty<out V> : KCallable<V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty0](../../kotlin.reflect/-k-property0/index) Represents a property without any kind of receiver. Such property is either originally declared in a receiverless context such as a package, or has the receiver bound to it. ``` interface KProperty0<out V> : KProperty<V>, () -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty1](../../kotlin.reflect/-k-property1/index) Represents a property, operations on which take one receiver as a parameter. ``` interface KProperty1<T, out V> : KProperty<V>, (T) -> V ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [KProperty2](../../kotlin.reflect/-k-property2/index) Represents a property, operations on which take two receivers as parameters, such as an extension property declared in a class. ``` interface KProperty2<D, E, out V> : KProperty<V>, (D, E) -> V ``` #### [KType](../../kotlin.reflect/-k-type/index) Represents a type. Type is usually either a class with optional type arguments, or a type parameter of some declaration, plus nullability. **Platform and version requirements:** JS (1.1), Native (1.3) ``` interface KType ``` **Platform and version requirements:** JVM (1.0) ``` interface KType : KAnnotatedElement ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KTypeParameter](../../kotlin.reflect/-k-type-parameter/index) Represents a declaration of a type parameter of a class or a callable. See the [Kotlin language documentation](../../../../../../docs/generics#generics) for more information. ``` interface KTypeParameter : KClassifier ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [KTypeProjection](../../kotlin.reflect/-k-type-projection/index) Represents a type projection. Type projection is usually the argument to another type in a type usage. For example, in the type `Array<out Number>`, `out Number` is the covariant projection of the type represented by the class `Number`. ``` data class KTypeProjection ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Lazy](../-lazy/index) Represents a value with lazy initialization. ``` interface Lazy<out T> ``` #### [LinkedHashMap](../../kotlin.collections/-linked-hash-map/index) Hash table based implementation of the [MutableMap](../../kotlin.collections/-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](../../kotlin.collections/-linked-hash-set/index) The implementation of the [MutableSet](../../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) interface, backed by a [LinkedHashMap](../../kotlin.collections/-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:** JS (1.1) #### [LinkStyle](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-link-style/index.html) Exposes the JavaScript [LinkStyle](https://developer.mozilla.org/en/docs/Web/API/LinkStyle) to Kotlin ``` interface LinkStyle ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [List](../../kotlin.collections/-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](../../kotlin.collections/-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](../../kotlin.collections/-list-iterator/index) An iterator over a collection that supports indexed access. ``` interface ListIterator<out T> : Iterator<T> ``` **Platform and version requirements:** JS (1.1) #### [Location](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-location/index.html) Exposes the JavaScript [Location](https://developer.mozilla.org/en/docs/Web/API/Location) to Kotlin ``` abstract class Location ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongArray](../-long-array/index) An array of longs. When targeting the JVM, instances of this class are represented as `long[]`. ``` class LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [LongIterator](../../kotlin.collections/-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) #### [LongProgression](../../kotlin.ranges/-long-progression/index) A progression of values of type `Long`. ``` open class LongProgression : Iterable<Long> ``` **Platform and version requirements:** Native (1.3) #### [ManagedType](../../kotlinx.cinterop/-managed-type/index) ``` abstract class ManagedType<T : CStructVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Map](../../kotlin.collections/-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](../../kotlin.collections/-mutable-map/index#kotlin.collections.MutableMap) interface. ``` interface Map<K, out V> ``` #### [MatchGroup](../../kotlin.text/-match-group/index) Represents the results from a single capturing group within a MatchResult of [Regex](../../kotlin.text/-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](../../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.1), JS (1.1), Native (1.1) #### [MatchNamedGroupCollection](../../kotlin.text/-match-named-group-collection/index) Extends [MatchGroupCollection](../../kotlin.text/-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](../../kotlin.text/-match-result/index) Represents the results from a single regular expression match. ``` interface MatchResult ``` **Platform and version requirements:** JS (1.1) #### [MediaDeviceInfo](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-device-info/index.html) Exposes the JavaScript [MediaDeviceInfo](https://developer.mozilla.org/en/docs/Web/API/MediaDeviceInfo) to Kotlin ``` abstract class MediaDeviceInfo ``` **Platform and version requirements:** JS (1.1) #### [MediaDeviceKind](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-device-kind.html) ``` interface MediaDeviceKind ``` **Platform and version requirements:** JS (1.1) #### [MediaEncryptedEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-encrypted-event-init/index.html) ``` interface MediaEncryptedEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [MediaError](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-media-error/index.html) Exposes the JavaScript [MediaError](https://developer.mozilla.org/en/docs/Web/API/MediaError) to Kotlin ``` abstract class MediaError ``` **Platform and version requirements:** JS (1.1) #### [MediaKeyMessageEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-message-event-init/index.html) ``` interface MediaKeyMessageEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [MediaKeyMessageType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-message-type.html) ``` interface MediaKeyMessageType ``` **Platform and version requirements:** JS (1.1) #### [MediaKeys](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-keys/index.html) Exposes the JavaScript [MediaKeys](https://developer.mozilla.org/en/docs/Web/API/MediaKeys) to Kotlin ``` abstract class MediaKeys ``` **Platform and version requirements:** JS (1.1) #### [MediaKeySessionType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-session-type.html) ``` interface MediaKeySessionType ``` **Platform and version requirements:** JS (1.1) #### [MediaKeysRequirement](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-keys-requirement.html) ``` interface MediaKeysRequirement ``` **Platform and version requirements:** JS (1.1) #### [MediaKeyStatus](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-status.html) ``` interface MediaKeyStatus ``` **Platform and version requirements:** JS (1.1) #### [MediaKeyStatusMap](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-status-map/index.html) Exposes the JavaScript [MediaKeyStatusMap](https://developer.mozilla.org/en/docs/Web/API/MediaKeyStatusMap) to Kotlin ``` abstract class MediaKeyStatusMap ``` **Platform and version requirements:** JS (1.1) #### [MediaKeySystemAccess](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-system-access/index.html) Exposes the JavaScript [MediaKeySystemAccess](https://developer.mozilla.org/en/docs/Web/API/MediaKeySystemAccess) to Kotlin ``` abstract class MediaKeySystemAccess ``` **Platform and version requirements:** JS (1.1) #### [MediaKeySystemConfiguration](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-system-configuration/index.html) Exposes the JavaScript [MediaKeySystemConfiguration](https://developer.mozilla.org/en/docs/Web/API/MediaKeySystemConfiguration) to Kotlin ``` interface MediaKeySystemConfiguration ``` **Platform and version requirements:** JS (1.1) #### [MediaKeySystemMediaCapability](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.encryptedmedia/-media-key-system-media-capability/index.html) ``` interface MediaKeySystemMediaCapability ``` **Platform and version requirements:** JS (1.1) #### [MediaList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-media-list/index.html) ``` abstract class MediaList : ItemArrayLike<String> ``` **Platform and version requirements:** JS (1.1) #### [MediaProvider](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-media-provider.html) ``` interface MediaProvider ``` **Platform and version requirements:** JS (1.1) #### [MediaQueryListEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-media-query-list-event-init/index.html) ``` interface MediaQueryListEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [MediaStreamConstraints](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-stream-constraints/index.html) Exposes the JavaScript [MediaStreamConstraints](https://developer.mozilla.org/en/docs/Web/API/MediaStreamConstraints) to Kotlin ``` interface MediaStreamConstraints ``` **Platform and version requirements:** JS (1.1) #### [MediaStreamTrackEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-stream-track-event-init/index.html) ``` interface MediaStreamTrackEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [MediaStreamTrackState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-stream-track-state.html) ``` interface MediaStreamTrackState ``` **Platform and version requirements:** JS (1.1) #### [MediaTrackCapabilities](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-track-capabilities/index.html) ``` interface MediaTrackCapabilities ``` **Platform and version requirements:** JS (1.1) #### [MediaTrackConstraints](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-track-constraints/index.html) Exposes the JavaScript [MediaTrackConstraints](https://developer.mozilla.org/en/docs/Web/API/MediaTrackConstraints) to Kotlin ``` interface MediaTrackConstraints : MediaTrackConstraintSet ``` **Platform and version requirements:** JS (1.1) #### [MediaTrackConstraintSet](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-track-constraint-set/index.html) ``` interface MediaTrackConstraintSet ``` **Platform and version requirements:** JS (1.1) #### [MediaTrackSettings](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-track-settings/index.html) Exposes the JavaScript [MediaTrackSettings](https://developer.mozilla.org/en/docs/Web/API/MediaTrackSettings) to Kotlin ``` interface MediaTrackSettings ``` **Platform and version requirements:** JS (1.1) #### [MediaTrackSupportedConstraints](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-media-track-supported-constraints/index.html) Exposes the JavaScript [MediaTrackSupportedConstraints](https://developer.mozilla.org/en/docs/Web/API/MediaTrackSupportedConstraints) to Kotlin ``` interface MediaTrackSupportedConstraints ``` **Platform and version requirements:** JS (1.1) #### [MessageChannel](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-message-channel/index.html) Exposes the JavaScript [MessageChannel](https://developer.mozilla.org/en/docs/Web/API/MessageChannel) to Kotlin ``` open class MessageChannel ``` **Platform and version requirements:** JS (1.1) #### [MessageEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-message-event-init/index.html) ``` interface MessageEventInit : EventInit ``` **Platform and version requirements:** JVM (1.3) #### [Metadata](../-metadata/index) This annotation is present on any class file produced by the Kotlin compiler and is read by the compiler and reflection. Parameters have very short JVM names on purpose: these names appear in all generated class files, and we'd like to reduce their size. ``` annotation class Metadata ``` **Platform and version requirements:** JS (1.1) #### [MimeType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-mime-type/index.html) Exposes the JavaScript [MimeType](https://developer.mozilla.org/en/docs/Web/API/MimeType) to Kotlin ``` abstract class MimeType ``` **Platform and version requirements:** JS (1.1) #### [MimeTypeArray](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-mime-type-array/index.html) Exposes the JavaScript [MimeTypeArray](https://developer.mozilla.org/en/docs/Web/API/MimeTypeArray) to Kotlin ``` abstract class MimeTypeArray : ItemArrayLike<MimeType> ``` **Platform and version requirements:** JS (1.1) #### [MouseEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-mouse-event-init/index.html) ``` interface MouseEventInit : EventModifierInit ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MustBeDocumented](../../kotlin.annotation/-must-be-documented/index) This meta-annotation determines that an annotation is a part of public API and therefore should be included in the generated documentation for the element to which the annotation is applied. ``` annotation class MustBeDocumented ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableCollection](../../kotlin.collections/-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:** Native (1.3) #### [MutableData](../../kotlin.native.concurrent/-mutable-data/index) Mutable concurrently accessible data buffer. Could be accessed from several workers simulteniously. ``` class MutableData ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableEntry](../../kotlin.collections/-mutable-map/-mutable-entry/index) Represents a key/value pair held by a [MutableMap](../../kotlin.collections/-mutable-map/index#kotlin.collections.MutableMap). ``` interface MutableEntry<K, V> : Entry<K, V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MutableIterable](../../kotlin.collections/-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](../../kotlin.collections/-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](../../kotlin.collections/-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](../../kotlin.collections/-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](../../kotlin.collections/-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](../../kotlin.collections/-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> ``` **Platform and version requirements:** JS (1.1) #### [MutationObserver](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-mutation-observer/index.html) Exposes the JavaScript [MutationObserver](https://developer.mozilla.org/en/docs/Web/API/MutationObserver) to Kotlin ``` open class MutationObserver ``` **Platform and version requirements:** JS (1.1) #### [MutationObserverInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-mutation-observer-init/index.html) Exposes the JavaScript [MutationObserverInit](https://developer.mozilla.org/en/docs/Web/API/MutationObserverInit) to Kotlin ``` interface MutationObserverInit ``` **Platform and version requirements:** JS (1.1) #### [MutationRecord](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-mutation-record/index.html) Exposes the JavaScript [MutationRecord](https://developer.mozilla.org/en/docs/Web/API/MutationRecord) to Kotlin ``` abstract class MutationRecord ``` **Platform and version requirements:** JS (1.1) #### [NamedNodeMap](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-named-node-map/index.html) Exposes the JavaScript [NamedNodeMap](https://developer.mozilla.org/en/docs/Web/API/NamedNodeMap) to Kotlin ``` abstract class NamedNodeMap : ItemArrayLike<Attr> ``` **Platform and version requirements:** Native (1.3) #### [NativeFreeablePlacement](../../kotlinx.cinterop/-native-freeable-placement/index) ``` interface NativeFreeablePlacement : NativePlacement ``` **Platform and version requirements:** JS (1.1) #### [nativeGetter](../../kotlin.js/native-getter/index) ``` annotation class nativeGetter ``` **Platform and version requirements:** Native (1.3) #### [nativeHeap](../../kotlinx.cinterop/native-heap/index) ``` object nativeHeap : NativeFreeablePlacement ``` **Platform and version requirements:** JS (1.1) #### [nativeInvoke](../../kotlin.js/native-invoke/index) ``` annotation class nativeInvoke ``` **Platform and version requirements:** Native (1.3) #### [NativePlacement](../../kotlinx.cinterop/-native-placement/index) ``` interface NativePlacement ``` **Platform and version requirements:** Native (1.3) #### [NativePointed](../../kotlinx.cinterop/-native-pointed/index) The entity which has an associated native pointer. Subtypes are supposed to represent interpretations of the pointed data or code. ``` open class NativePointed ``` **Platform and version requirements:** JS (1.1) #### [nativeSetter](../../kotlin.js/native-setter/index) ``` annotation class nativeSetter ``` **Platform and version requirements:** JS (1.1) #### [Navigator](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator/index.html) Exposes the JavaScript [Navigator](https://developer.mozilla.org/en/docs/Web/API/Navigator) to Kotlin ``` abstract class Navigator :      NavigatorID,     NavigatorLanguage,     NavigatorOnLine,     NavigatorContentUtils,     NavigatorCookies,     NavigatorPlugins,     NavigatorConcurrentHardware ``` **Platform and version requirements:** JS (1.1) #### [NavigatorConcurrentHardware](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-concurrent-hardware/index.html) Exposes the JavaScript [NavigatorConcurrentHardware](https://developer.mozilla.org/en/docs/Web/API/NavigatorConcurrentHardware) to Kotlin ``` interface NavigatorConcurrentHardware ``` **Platform and version requirements:** JS (1.1) #### [NavigatorContentUtils](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-content-utils/index.html) ``` interface NavigatorContentUtils ``` **Platform and version requirements:** JS (1.1) #### [NavigatorCookies](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-cookies/index.html) ``` interface NavigatorCookies ``` **Platform and version requirements:** JS (1.1) #### [NavigatorID](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-i-d/index.html) Exposes the JavaScript [NavigatorID](https://developer.mozilla.org/en/docs/Web/API/NavigatorID) to Kotlin ``` interface NavigatorID ``` **Platform and version requirements:** JS (1.1) #### [NavigatorLanguage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-language/index.html) Exposes the JavaScript [NavigatorLanguage](https://developer.mozilla.org/en/docs/Web/API/NavigatorLanguage) to Kotlin ``` interface NavigatorLanguage ``` **Platform and version requirements:** JS (1.1) #### [NavigatorOnLine](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-on-line/index.html) Exposes the JavaScript [NavigatorOnLine](https://developer.mozilla.org/en/docs/Web/API/NavigatorOnLine) to Kotlin ``` interface NavigatorOnLine ``` **Platform and version requirements:** JS (1.1) #### [NavigatorPlugins](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-navigator-plugins/index.html) Exposes the JavaScript [NavigatorPlugins](https://developer.mozilla.org/en/docs/Web/API/NavigatorPlugins) to Kotlin ``` interface NavigatorPlugins ``` **Platform and version requirements:** JS (1.1) #### [NodeFilter](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-node-filter/index.html) Exposes the JavaScript [NodeFilter](https://developer.mozilla.org/en/docs/Web/API/NodeFilter) to Kotlin ``` interface NodeFilter ``` **Platform and version requirements:** JS (1.1) #### [NodeIterator](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-node-iterator/index.html) Exposes the JavaScript [NodeIterator](https://developer.mozilla.org/en/docs/Web/API/NodeIterator) to Kotlin ``` abstract class NodeIterator ``` **Platform and version requirements:** JS (1.1) #### [NodeList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-node-list/index.html) Exposes the JavaScript [NodeList](https://developer.mozilla.org/en/docs/Web/API/NodeList) to Kotlin ``` abstract class NodeList : ItemArrayLike<Node> ``` **Platform and version requirements:** JS (1.1) #### [NonDocumentTypeChildNode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-non-document-type-child-node/index.html) Exposes the JavaScript [NonDocumentTypeChildNode](https://developer.mozilla.org/en/docs/Web/API/NonDocumentTypeChildNode) to Kotlin ``` interface NonDocumentTypeChildNode ``` **Platform and version requirements:** JS (1.1) #### [NonElementParentNode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-non-element-parent-node/index.html) ``` interface NonElementParentNode ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Nothing](../-nothing) Nothing has no instances. You can use Nothing to represent "a value that never exists": for example, if a function has the return type of Nothing, it means that it never returns (always throws an exception). ``` class Nothing ``` **Platform and version requirements:** JS (1.1) #### [NotificationAction](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-notification-action/index.html) ``` interface NotificationAction ``` **Platform and version requirements:** JS (1.1) #### [NotificationDirection](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-notification-direction.html) ``` interface NotificationDirection ``` **Platform and version requirements:** JS (1.1) #### [NotificationEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-notification-event-init/index.html) ``` interface NotificationEventInit : ExtendableEventInit ``` **Platform and version requirements:** JS (1.1) #### [NotificationOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-notification-options/index.html) ``` interface NotificationOptions ``` **Platform and version requirements:** JS (1.1) #### [NotificationPermission](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.notifications/-notification-permission.html) ``` interface NotificationPermission ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Number](../-number/index) Superclass for all platform classes representing numeric values. ``` abstract class Number ``` **Platform and version requirements:** Native (1.3) #### [ObjCAction](../../kotlinx.cinterop/-obj-c-action/index) Makes Kotlin method in Objective-C class accessible through Objective-C dispatch to be used as action sent by control in UIKit or AppKit. ``` annotation class ObjCAction ``` **Platform and version requirements:** Native (1.3) #### [ObjCClass](../../kotlinx.cinterop/-obj-c-class) ``` interface ObjCClass : ObjCObject ``` **Platform and version requirements:** Native (1.3) #### [ObjCClassOf](../../kotlinx.cinterop/-obj-c-class-of) ``` interface ObjCClassOf<T : ObjCObject> : ObjCClass ``` **Platform and version requirements:** Native (1.3) #### [ObjCConstructor](../../kotlinx.cinterop/-obj-c-constructor/index) ``` annotation class ObjCConstructor ``` **Platform and version requirements:** Native (1.3) #### [ObjCFactory](../../kotlinx.cinterop/-obj-c-factory/index) ``` annotation class ObjCFactory ``` **Platform and version requirements:** Native (1.3) #### [ObjCMethod](../../kotlinx.cinterop/-obj-c-method/index) ``` annotation class ObjCMethod ``` **Platform and version requirements:** Native (1.0) #### [ObjCName](../../kotlin.native/-obj-c-name/index) Instructs the Kotlin compiler to use a custom Objective-C and/or Swift name for this class, property, parameter or function. ``` annotation class ObjCName ``` **Platform and version requirements:** Native (1.3) #### [ObjCObject](../../kotlinx.cinterop/-obj-c-object) ``` interface ObjCObject ``` **Platform and version requirements:** Native (1.3) #### [ObjCObjectBase](../../kotlinx.cinterop/-obj-c-object-base/index) ``` abstract class ObjCObjectBase : ObjCObject ``` **Platform and version requirements:** Native (1.3) #### [ObjCOutlet](../../kotlinx.cinterop/-obj-c-outlet/index) Makes Kotlin property in Objective-C class settable through Objective-C dispatch to be used as IB outlet. ``` annotation class ObjCOutlet ``` **Platform and version requirements:** Native (1.3) #### [ObjCProtocol](../../kotlinx.cinterop/-obj-c-protocol) ``` interface ObjCProtocol : ObjCObject ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ObservableProperty](../../kotlin.properties/-observable-property/index) Implements the core logic of a property delegate for a read/write property that calls callback functions when changed. ``` abstract class ObservableProperty<V> :      ReadWriteProperty<Any?, V> ``` **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [OpenEndRange](../../kotlin.ranges/-open-end-range/index) Represents a range of values (for example, numbers or characters) where the upper bound is not included in the range. See the [Kotlin language documentation](../../../../../../docs/ranges) for more information. ``` interface OpenEndRange<T : Comparable<T>> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [OptIn](../-opt-in/index) Allows to use the API denoted by the given markers in the annotated file, declaration, or expression. If a declaration is annotated with [OptIn](../-opt-in/index), its usages are **not** required to opt in to that API. ``` annotation class OptIn ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [OptionalExpectation](../-optional-expectation/index) Marks an expected annotation class that it isn't required to have actual counterparts in all platforms. ``` annotation class OptionalExpectation ``` **Platform and version requirements:** JS (1.1) #### [OverconstrainedErrorEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-overconstrained-error-event-init/index.html) ``` interface OverconstrainedErrorEventInit : EventInit ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [OverloadResolutionByLambdaReturnType](../-overload-resolution-by-lambda-return-type/index) Enables overload selection based on the type of the value returned from lambda argument. ``` annotation class OverloadResolutionByLambdaReturnType ``` **Platform and version requirements:** JS (1.1) #### [PageTransitionEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-page-transition-event-init/index.html) ``` interface PageTransitionEventInit : EventInit ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Pair](../-pair/index) Represents a generic pair of two values. ``` data class Pair<out A, out B> : Serializable ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [ParameterName](../-parameter-name/index) Annotates type arguments of functional type and holds corresponding parameter name specified by the user in type declaration (if any). ``` annotation class ParameterName ``` **Platform and version requirements:** JS (1.1) #### [ParentNode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-parent-node/index.html) Exposes the JavaScript [ParentNode](https://developer.mozilla.org/en/docs/Web/API/ParentNode) to Kotlin ``` interface ParentNode ``` **Platform and version requirements:** JS (1.1) #### [Path2D](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-path2-d/index.html) Exposes the JavaScript [Path2D](https://developer.mozilla.org/en/docs/Web/API/Path2D) to Kotlin ``` open class Path2D : CanvasPath ``` **Platform and version requirements:** JS (1.1) #### [PerformanceNavigation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.performance/-performance-navigation/index.html) Exposes the JavaScript [PerformanceNavigation](https://developer.mozilla.org/en/docs/Web/API/PerformanceNavigation) to Kotlin ``` abstract class PerformanceNavigation ``` **Platform and version requirements:** JS (1.1) #### [PerformanceTiming](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.performance/-performance-timing/index.html) Exposes the JavaScript [PerformanceTiming](https://developer.mozilla.org/en/docs/Web/API/PerformanceTiming) to Kotlin ``` abstract class PerformanceTiming ``` **Platform and version requirements:** Native (1.3) #### [Pinned](../../kotlinx.cinterop/-pinned/index) ``` data class Pinned<out T : Any> ``` **Platform and version requirements:** Native (1.3) #### [Platform](../../kotlin.native/-platform/index) Object describing the current platform program executes upon. ``` object Platform ``` **Platform and version requirements:** JS (1.1) #### [Plugin](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-plugin/index.html) Exposes the JavaScript [Plugin](https://developer.mozilla.org/en/docs/Web/API/Plugin) to Kotlin ``` abstract class Plugin : ItemArrayLike<MimeType> ``` **Platform and version requirements:** JS (1.1) #### [PluginArray](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-plugin-array/index.html) Exposes the JavaScript [PluginArray](https://developer.mozilla.org/en/docs/Web/API/PluginArray) to Kotlin ``` abstract class PluginArray : ItemArrayLike<Plugin> ``` **Platform and version requirements:** JS (1.1) #### [PointerEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.pointerevents/-pointer-event-init/index.html) ``` interface PointerEventInit : MouseEventInit ``` **Platform and version requirements:** JS (1.1) #### [PopStateEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-pop-state-event-init/index.html) ``` interface PopStateEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [PremultiplyAlpha](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-premultiply-alpha.html) ``` interface PremultiplyAlpha ``` **Platform and version requirements:** JS (1.1) #### [ProgressEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.xhr/-progress-event-init/index.html) ``` interface ProgressEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [Promise](../../kotlin.js/-promise/index) Exposes the JavaScript [Promise object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) to Kotlin. ``` open class Promise<out T> ``` **Platform and version requirements:** JS (1.1) #### [PromiseRejectionEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-promise-rejection-event-init/index.html) ``` interface PromiseRejectionEventInit : EventInit ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [PropertyDelegateProvider](../../kotlin.properties/-property-delegate-provider/index) Base interface that can be used for implementing property delegate providers. ``` fun interface PropertyDelegateProvider<in T, out D> ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [PublishedApi](../-published-api/index) When applied to a class or a member with internal visibility allows to use it from public inline functions and makes it effectively public. ``` annotation class PublishedApi ``` **Platform and version requirements:** JVM (1.0) #### [PurelyImplements](../../kotlin.jvm/-purely-implements/index) Instructs the Kotlin compiler to treat annotated Java class as pure implementation of given Kotlin interface. "Pure" means here that each type parameter of class becomes non-platform type argument of that interface. ``` annotation class PurelyImplements ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Random](../../kotlin.random/-random/index) An abstract class that is implemented by random number generator algorithms. ``` abstract class Random ``` #### [RandomAccess](../../kotlin.collections/-random-access) Marker interface indicating that the [List](../../kotlin.collections/-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:** JS (1.1) #### [Range](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-range/index.html) Exposes the JavaScript [Range](https://developer.mozilla.org/en/docs/Web/API/Range) to Kotlin ``` open class Range ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ReadOnlyProperty](../../kotlin.properties/-read-only-property/index) Base interface that can be used for implementing property delegates of read-only properties. ``` fun interface ReadOnlyProperty<in T, out V> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ReadWriteProperty](../../kotlin.properties/-read-write-property/index) Base interface that can be used for implementing property delegates of read-write properties. ``` interface ReadWriteProperty<in T, V> : ReadOnlyProperty<T, V> ``` **Platform and version requirements:** JS (1.1) #### [ReadyState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediasource/-ready-state.html) ``` interface ReadyState ``` **Platform and version requirements:** Native (1.0) #### [RefinesInSwift](../../kotlin.native/-refines-in-swift/index) Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as `swift_private` in the generated Objective-C API. ``` annotation class RefinesInSwift ``` #### [Regex](../../kotlin.text/-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 ``` **Platform and version requirements:** JS (1.1) #### [RegExp](../../kotlin.js/-reg-exp/index) Exposes the JavaScript [RegExp object](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp) to Kotlin. ``` class RegExp ``` **Platform and version requirements:** JS (1.1) #### [RegExpMatch](../../kotlin.js/-reg-exp-match/index) Represents the return value of [RegExp.exec](../../kotlin.js/-reg-exp/exec). ``` interface RegExpMatch ``` **Platform and version requirements:** JS (1.1) #### [RegistrationOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-registration-options/index.html) ``` interface RegistrationOptions ``` **Platform and version requirements:** JS (1.1) #### [RelatedEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-related-event-init/index.html) ``` interface RelatedEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [RenderingContext](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-rendering-context.html) ``` interface RenderingContext ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Repeatable](../../kotlin.annotation/-repeatable/index) This meta-annotation determines that an annotation is applicable twice or more on a single code element ``` annotation class Repeatable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ReplaceWith](../-replace-with/index) Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. ``` annotation class ReplaceWith ``` **Platform and version requirements:** JS (1.1) #### [Request](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request/index.html) Exposes the JavaScript [Request](https://developer.mozilla.org/en/docs/Web/API/Request) to Kotlin ``` open class Request : Body ``` **Platform and version requirements:** JS (1.1) #### [RequestCache](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-cache.html) ``` interface RequestCache ``` **Platform and version requirements:** JS (1.1) #### [RequestCredentials](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-credentials.html) ``` interface RequestCredentials ``` **Platform and version requirements:** JS (1.1) #### [RequestDestination](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-destination.html) ``` interface RequestDestination ``` **Platform and version requirements:** JS (1.1) #### [RequestInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-init/index.html) ``` interface RequestInit ``` **Platform and version requirements:** JS (1.1) #### [RequestMode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-mode.html) ``` interface RequestMode ``` **Platform and version requirements:** JS (1.1) #### [RequestRedirect](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-redirect.html) ``` interface RequestRedirect ``` **Platform and version requirements:** JS (1.1) #### [RequestType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-request-type.html) ``` interface RequestType ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RequiresOptIn](../-requires-opt-in/index) Signals that the annotated annotation class is a marker of an API that requires an explicit opt-in. ``` annotation class RequiresOptIn ``` **Platform and version requirements:** JS (1.1) #### [ResizeQuality](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-resize-quality.html) ``` interface ResizeQuality ``` **Platform and version requirements:** JS (1.1) #### [Response](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-response/index.html) Exposes the JavaScript [Response](https://developer.mozilla.org/en/docs/Web/API/Response) to Kotlin ``` open class Response : Body ``` **Platform and version requirements:** JS (1.1) #### [ResponseInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-response-init/index.html) ``` interface ResponseInit ``` **Platform and version requirements:** JS (1.1) #### [ResponseType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.fetch/-response-type.html) ``` interface ResponseType ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [RestrictsSuspension](../../kotlin.coroutines/-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 ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Result](../-result/index) A discriminated union that encapsulates a successful outcome with a value of type [T](../-result/index#T) or a failure with an arbitrary [Throwable](../-throwable/index#kotlin.Throwable) exception. ``` class Result<out T> : Serializable ``` **Platform and version requirements:** Native (1.3) #### [Retain](../../kotlin.native/-retain/index) Preserve the function entry point during global optimizations. ``` annotation class Retain ``` **Platform and version requirements:** Native (1.3) #### [RetainForTarget](../../kotlin.native/-retain-for-target/index) Preserve the function entry point during global optimizations, only for the given target. ``` annotation class RetainForTarget ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Retention](../../kotlin.annotation/-retention/index) This meta-annotation determines whether an annotation is stored in binary output and visible for reflection. By default, both are true. ``` annotation class Retention ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [Returns](../../kotlin.contracts/-returns) Describes a situation when a function returns normally with a given return value. ``` interface Returns : SimpleEffect ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ReturnsNotNull](../../kotlin.contracts/-returns-not-null) Describes a situation when a function returns normally with any non-null return value. ``` interface ReturnsNotNull : SimpleEffect ``` **Platform and version requirements:** JS (1.1) #### [Screen](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-screen/index.html) Exposes the JavaScript [Screen](https://developer.mozilla.org/en/docs/Web/API/Screen) to Kotlin ``` abstract class Screen ``` **Platform and version requirements:** JS (1.1) #### [ScrollBehavior](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-behavior.html) ``` interface ScrollBehavior ``` **Platform and version requirements:** JS (1.1) #### [ScrollIntoViewOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-into-view-options/index.html) ``` interface ScrollIntoViewOptions : ScrollOptions ``` **Platform and version requirements:** JS (1.1) #### [ScrollLogicalPosition](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-logical-position.html) ``` interface ScrollLogicalPosition ``` **Platform and version requirements:** JS (1.1) #### [ScrollOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-options/index.html) ``` interface ScrollOptions ``` **Platform and version requirements:** JS (1.1) #### [ScrollRestoration](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-restoration.html) ``` interface ScrollRestoration ``` **Platform and version requirements:** JS (1.1) #### [ScrollToOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-scroll-to-options/index.html) Exposes the JavaScript [ScrollToOptions](https://developer.mozilla.org/en/docs/Web/API/ScrollToOptions) to Kotlin ``` interface ScrollToOptions : ScrollOptions ``` **Platform and version requirements:** JS (1.1) #### [SelectionMode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-selection-mode.html) ``` interface SelectionMode ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Sequence](../../kotlin.sequences/-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](../../kotlin.sequences/-sequence-scope/index) The scope for yielding values of a [Sequence](../../kotlin.sequences/-sequence/index) or an [Iterator](../../kotlin.collections/-iterator/index#kotlin.collections.Iterator), provides [yield](../../kotlin.sequences/-sequence-scope/yield) and [yieldAll](../../kotlin.sequences/-sequence-scope/yield-all) suspension functions. ``` abstract class SequenceScope<in T> ``` **Platform and version requirements:** JS (1.1) #### [ServiceWorkerMessageEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-service-worker-message-event-init/index.html) ``` interface ServiceWorkerMessageEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [ServiceWorkerState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-service-worker-state.html) ``` interface ServiceWorkerState ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Set](../../kotlin.collections/-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](../../kotlin.collections/-mutable-set/index#kotlin.collections.MutableSet) interface. ``` interface Set<out E> : Collection<E> ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../../kotlin.reflect/-k-mutable-property/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KProperty.Accessor<V>, KFunction<Unit> ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../../kotlin.reflect/-k-mutable-property0/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<V> : KMutableProperty.Setter<V>, (V) -> Unit ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../../kotlin.reflect/-k-mutable-property1/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<T, V> :      KMutableProperty.Setter<V>,     (T, V) -> Unit ``` **Platform and version requirements:** JVM (1.0) #### [Setter](../../kotlin.reflect/-k-mutable-property2/-setter) Setter of the property is a `set` method declared alongside the property. ``` interface Setter<D, E, V> :      KMutableProperty.Setter<V>,     (D, E, V) -> Unit ``` **Platform and version requirements:** JS (1.1) #### [Settings](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-settings.html) ``` interface Settings ``` **Platform and version requirements:** JS (1.1) #### [ShadowAnimation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-shadow-animation/index.html) ``` open class ShadowAnimation ``` **Platform and version requirements:** JS (1.1) #### [ShadowRootInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-shadow-root-init/index.html) ``` interface ShadowRootInit ``` **Platform and version requirements:** JS (1.1) #### [ShadowRootMode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-shadow-root-mode.html) ``` interface ShadowRootMode ``` **Platform and version requirements:** Native (1.0) #### [SharedImmutable](../../kotlin.native.concurrent/-shared-immutable/index) Note: this annotation has effect only in Kotlin/Native with legacy memory manager. ``` annotation class SharedImmutable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ShortArray](../-short-array/index) An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`. ``` class ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ShortIterator](../../kotlin.collections/-short-iterator/index) An iterator over a sequence of values of type `Short`. ``` abstract class ShortIterator : Iterator<Short> ``` **Platform and version requirements:** Native (1.0) #### [ShouldRefineInSwift](../../kotlin.native/-should-refine-in-swift/index) Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API. ``` annotation class ShouldRefineInSwift ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [SimpleEffect](../../kotlin.contracts/-simple-effect/index) An effect that can be observed after a function invocation. ``` interface SimpleEffect : Effect ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [SinceKotlin](../-since-kotlin/index) Specifies the first version of Kotlin where a declaration has appeared. Using the declaration and specifying an older API version (via the `-api-version` command line option) will result in an error. ``` annotation class SinceKotlin ``` **Platform and version requirements:** Native (1.3) #### [SkiaRefCnt](../../kotlinx.cinterop/-skia-ref-cnt) ``` interface SkiaRefCnt ``` **Platform and version requirements:** JS (1.1) #### [Slotable](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-slotable/index.html) Exposes the JavaScript [Slotable](https://developer.mozilla.org/en/docs/Web/API/Slotable) to Kotlin ``` interface Slotable ``` **Platform and version requirements:** Native (1.3) #### [StableRef](../../kotlinx.cinterop/-stable-ref/index) ``` class StableRef<out T : Any> ``` **Platform and version requirements:** JS (1.1) #### [Storage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-storage/index.html) Exposes the JavaScript [Storage](https://developer.mozilla.org/en/docs/Web/API/Storage) to Kotlin ``` abstract class Storage ``` **Platform and version requirements:** JS (1.1) #### [StorageEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-storage-event-init/index.html) ``` interface StorageEventInit : EventInit ``` **Platform and version requirements:** JVM (1.0) #### [Strictfp](../../kotlin.jvm/-strictfp/index) Marks the JVM method generated from the annotated function as `strictfp`, meaning that the precision of floating point operations performed inside the method needs to be restricted in order to achieve better portability. ``` annotation class Strictfp ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [String](../-string/index) The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. ``` class String : Comparable<String>, CharSequence ``` #### [StringBuilder](../../kotlin.text/-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:** JS (1.1) #### [StyleSheet](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-style-sheet/index.html) Exposes the JavaScript [StyleSheet](https://developer.mozilla.org/en/docs/Web/API/StyleSheet) to Kotlin ``` abstract class StyleSheet ``` **Platform and version requirements:** JS (1.1) #### [StyleSheetList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-style-sheet-list/index.html) Exposes the JavaScript [StyleSheetList](https://developer.mozilla.org/en/docs/Web/API/StyleSheetList) to Kotlin ``` abstract class StyleSheetList : ItemArrayLike<StyleSheet> ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [SubclassOptInRequired](../-subclass-opt-in-required/index) Annotation that marks open for subclassing classes and interfaces, and makes implementation and extension of such declarations as requiring an explicit opt-in. ``` annotation class SubclassOptInRequired ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Suppress](../-suppress/index) Suppresses the given compilation warnings in the annotated element. ``` annotation class Suppress ``` **Platform and version requirements:** Native (1.3) #### [SuspendFunction](../../kotlin.coroutines/-suspend-function) Represents a value of a functional type, such as a lambda, an anonymous function or a function reference. ``` interface SuspendFunction<out R> ``` **Platform and version requirements:** JS (1.1) #### [SVGAngle](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-angle/index.html) Exposes the JavaScript [SVGAngle](https://developer.mozilla.org/en/docs/Web/API/SVGAngle) to Kotlin ``` abstract class SVGAngle ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedAngle](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-angle/index.html) Exposes the JavaScript [SVGAnimatedAngle](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedAngle) to Kotlin ``` abstract class SVGAnimatedAngle ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedBoolean](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-boolean/index.html) Exposes the JavaScript [SVGAnimatedBoolean](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedBoolean) to Kotlin ``` abstract class SVGAnimatedBoolean ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedEnumeration](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-enumeration/index.html) Exposes the JavaScript [SVGAnimatedEnumeration](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedEnumeration) to Kotlin ``` abstract class SVGAnimatedEnumeration ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedInteger](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-integer/index.html) Exposes the JavaScript [SVGAnimatedInteger](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedInteger) to Kotlin ``` abstract class SVGAnimatedInteger ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedLength](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-length/index.html) Exposes the JavaScript [SVGAnimatedLength](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedLength) to Kotlin ``` abstract class SVGAnimatedLength ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedLengthList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-length-list/index.html) Exposes the JavaScript [SVGAnimatedLengthList](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedLengthList) to Kotlin ``` abstract class SVGAnimatedLengthList ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedNumber](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-number/index.html) Exposes the JavaScript [SVGAnimatedNumber](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedNumber) to Kotlin ``` abstract class SVGAnimatedNumber ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedNumberList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-number-list/index.html) Exposes the JavaScript [SVGAnimatedNumberList](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedNumberList) to Kotlin ``` abstract class SVGAnimatedNumberList ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedPoints](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-points/index.html) Exposes the JavaScript [SVGAnimatedPoints](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedPoints) to Kotlin ``` interface SVGAnimatedPoints ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedPreserveAspectRatio](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-preserve-aspect-ratio/index.html) Exposes the JavaScript [SVGAnimatedPreserveAspectRatio](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedPreserveAspectRatio) to Kotlin ``` abstract class SVGAnimatedPreserveAspectRatio ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedRect](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-rect/index.html) Exposes the JavaScript [SVGAnimatedRect](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedRect) to Kotlin ``` abstract class SVGAnimatedRect ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedString](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-string/index.html) Exposes the JavaScript [SVGAnimatedString](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedString) to Kotlin ``` abstract class SVGAnimatedString ``` **Platform and version requirements:** JS (1.1) #### [SVGAnimatedTransformList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-animated-transform-list/index.html) Exposes the JavaScript [SVGAnimatedTransformList](https://developer.mozilla.org/en/docs/Web/API/SVGAnimatedTransformList) to Kotlin ``` abstract class SVGAnimatedTransformList ``` **Platform and version requirements:** JS (1.1) #### [SVGBoundingBoxOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-bounding-box-options/index.html) ``` interface SVGBoundingBoxOptions ``` **Platform and version requirements:** JS (1.1) #### [SVGElementInstance](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-element-instance/index.html) ``` interface SVGElementInstance ``` **Platform and version requirements:** JS (1.1) #### [SVGFitToViewBox](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-fit-to-view-box/index.html) ``` interface SVGFitToViewBox ``` **Platform and version requirements:** JS (1.1) #### [SVGLength](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-length/index.html) Exposes the JavaScript [SVGLength](https://developer.mozilla.org/en/docs/Web/API/SVGLength) to Kotlin ``` abstract class SVGLength ``` **Platform and version requirements:** JS (1.1) #### [SVGLengthList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-length-list/index.html) Exposes the JavaScript [SVGLengthList](https://developer.mozilla.org/en/docs/Web/API/SVGLengthList) to Kotlin ``` abstract class SVGLengthList ``` **Platform and version requirements:** JS (1.1) #### [SVGNameList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-name-list/index.html) ``` abstract class SVGNameList ``` **Platform and version requirements:** JS (1.1) #### [SVGNumber](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-number/index.html) Exposes the JavaScript [SVGNumber](https://developer.mozilla.org/en/docs/Web/API/SVGNumber) to Kotlin ``` abstract class SVGNumber ``` **Platform and version requirements:** JS (1.1) #### [SVGNumberList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-number-list/index.html) Exposes the JavaScript [SVGNumberList](https://developer.mozilla.org/en/docs/Web/API/SVGNumberList) to Kotlin ``` abstract class SVGNumberList ``` **Platform and version requirements:** JS (1.1) #### [SVGPointList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-point-list/index.html) ``` abstract class SVGPointList ``` **Platform and version requirements:** JS (1.1) #### [SVGPreserveAspectRatio](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-preserve-aspect-ratio/index.html) Exposes the JavaScript [SVGPreserveAspectRatio](https://developer.mozilla.org/en/docs/Web/API/SVGPreserveAspectRatio) to Kotlin ``` abstract class SVGPreserveAspectRatio ``` **Platform and version requirements:** JS (1.1) #### [SVGStringList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-string-list/index.html) Exposes the JavaScript [SVGStringList](https://developer.mozilla.org/en/docs/Web/API/SVGStringList) to Kotlin ``` abstract class SVGStringList ``` **Platform and version requirements:** JS (1.1) #### [SVGTests](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-tests/index.html) Exposes the JavaScript [SVGTests](https://developer.mozilla.org/en/docs/Web/API/SVGTests) to Kotlin ``` interface SVGTests ``` **Platform and version requirements:** JS (1.1) #### [SVGTransform](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-transform/index.html) Exposes the JavaScript [SVGTransform](https://developer.mozilla.org/en/docs/Web/API/SVGTransform) to Kotlin ``` abstract class SVGTransform ``` **Platform and version requirements:** JS (1.1) #### [SVGTransformList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-transform-list/index.html) Exposes the JavaScript [SVGTransformList](https://developer.mozilla.org/en/docs/Web/API/SVGTransformList) to Kotlin ``` abstract class SVGTransformList ``` **Platform and version requirements:** JS (1.1) #### [SVGUnitTypes](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-unit-types/index.html) Exposes the JavaScript [SVGUnitTypes](https://developer.mozilla.org/en/docs/Web/API/SVGUnitTypes) to Kotlin ``` interface SVGUnitTypes ``` **Platform and version requirements:** JS (1.1) #### [SVGURIReference](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-u-r-i-reference/index.html) Exposes the JavaScript [SVGURIReference](https://developer.mozilla.org/en/docs/Web/API/SVGURIReference) to Kotlin ``` interface SVGURIReference ``` **Platform and version requirements:** JS (1.1) #### [SVGZoomAndPan](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.svg/-s-v-g-zoom-and-pan/index.html) Exposes the JavaScript [SVGZoomAndPan](https://developer.mozilla.org/en/docs/Web/API/SVGZoomAndPan) to Kotlin ``` interface SVGZoomAndPan ``` **Platform and version requirements:** Native (1.3) #### [SymbolName](../../kotlin.native/-symbol-name/index) This is a dangerous deprecated and internal annotation. Please avoid using it. ``` annotation class SymbolName ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [Synchronized](../../kotlin.jvm/-synchronized/index) Marks the JVM method generated from the annotated function as `synchronized`, meaning that the method will be protected from concurrent execution by multiple threads by the monitor of the instance (or, for static methods, the class) on which the method is defined. ``` annotation class Synchronized ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Target](../../kotlin.annotation/-target/index) This meta-annotation indicates the kinds of code elements which are possible targets of an annotation. ``` annotation class Target ``` **Platform and version requirements:** JS (1.1) #### [TexImageSource](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-tex-image-source.html) ``` interface TexImageSource ``` **Platform and version requirements:** JS (1.1) #### [TextMetrics](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-text-metrics/index.html) Exposes the JavaScript [TextMetrics](https://developer.mozilla.org/en/docs/Web/API/TextMetrics) to Kotlin ``` abstract class TextMetrics ``` **Platform and version requirements:** JS (1.1) #### [TextTrackCueList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-text-track-cue-list/index.html) ``` abstract class TextTrackCueList ``` **Platform and version requirements:** JS (1.1) #### [TextTrackKind](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-text-track-kind.html) ``` interface TextTrackKind ``` **Platform and version requirements:** JS (1.1) #### [TextTrackMode](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-text-track-mode.html) ``` interface TextTrackMode ``` **Platform and version requirements:** Native (1.0) #### [ThreadLocal](../../kotlin.native.concurrent/-thread-local/index) Marks a top level property with a backing field or an object as thread local. The object remains mutable and it is possible to change its state, but every thread will have a distinct copy of this object, so changes in one thread are not reflected in another. ``` annotation class ThreadLocal ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Throwable](../-throwable/index) The base class for all errors and exceptions. Only instances of this class can be thrown or caught. ``` open class Throwable ``` #### [Throws](../-throws/index) This annotation indicates what exceptions should be declared by a function when compiled to a platform method in Kotlin/JVM and Kotlin/Native. **Platform and version requirements:** Native (1.4) ``` annotation class Throws ``` **Platform and version requirements:** JVM (1.4) ``` typealias Throws = Throws ``` **Platform and version requirements:** JVM (1.0) #### [Throws](../../kotlin.jvm/-throws/index) This annotation indicates what exceptions should be declared by a function when compiled to a JVM method. ``` annotation class Throws ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [TimedValue](../../kotlin.time/-timed-value/index) Data class representing a result of executing an action, along with the duration of elapsed time interval. ``` data class TimedValue<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [TimeMark](../../kotlin.time/-time-mark/index) Represents a time point notched on a particular [TimeSource](../../kotlin.time/-time-source/index). Remains bound to the time source it was taken from and allows querying for the duration of time elapsed from that point (see the function [elapsedNow](../../kotlin.time/-time-mark/elapsed-now)). ``` interface TimeMark ``` **Platform and version requirements:** JS (1.1) #### [TimeRanges](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-time-ranges/index.html) Exposes the JavaScript [TimeRanges](https://developer.mozilla.org/en/docs/Web/API/TimeRanges) to Kotlin ``` abstract class TimeRanges ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [TimeSource](../../kotlin.time/-time-source/index) A source of time for measuring time intervals. ``` interface TimeSource ``` **Platform and version requirements:** JS (1.1) #### [Touch](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-touch/index.html) Exposes the JavaScript [Touch](https://developer.mozilla.org/en/docs/Web/API/Touch) to Kotlin ``` abstract class Touch ``` **Platform and version requirements:** JS (1.1) #### [TouchList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-touch-list/index.html) ``` abstract class TouchList : ItemArrayLike<Touch> ``` **Platform and version requirements:** JS (1.1) #### [TrackEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-track-event-init/index.html) ``` interface TrackEventInit : EventInit ``` **Platform and version requirements:** JVM (1.0) #### [Transient](../../kotlin.jvm/-transient/index) Marks the JVM backing field of the annotated property as `transient`, meaning that it is not part of the default serialized form of the object. ``` annotation class Transient ``` **Platform and version requirements:** JS (1.1) #### [TreeWalker](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-tree-walker/index.html) Exposes the JavaScript [TreeWalker](https://developer.mozilla.org/en/docs/Web/API/TreeWalker) to Kotlin ``` abstract class TreeWalker ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Triple](../-triple/index) Represents a triad of values ``` data class Triple<out A, out B, out C> : Serializable ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Typography](../../kotlin.text/-typography/index) Defines names for Unicode symbols used in proper Typography. ``` object Typography ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UByte](../-u-byte/index) ``` class UByte : Comparable<UByte> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UByteArray](../-u-byte-array/index) ``` class UByteArray : Collection<UByte> ``` **Platform and version requirements:** JS (1.1) #### [UIEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-u-i-event-init/index.html) ``` interface UIEventInit : EventInit ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UInt](../-u-int/index) ``` class UInt : Comparable<UInt> ``` **Platform and version requirements:** JS (1.1) #### [Uint16Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-uint16-array/index.html) Exposes the JavaScript [Uint16Array](https://developer.mozilla.org/en/docs/Web/API/Uint16Array) to Kotlin ``` open class Uint16Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Uint32Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-uint32-array/index.html) Exposes the JavaScript [Uint32Array](https://developer.mozilla.org/en/docs/Web/API/Uint32Array) to Kotlin ``` open class Uint32Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Uint8Array](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-uint8-array/index.html) Exposes the JavaScript [Uint8Array](https://developer.mozilla.org/en/docs/Web/API/Uint8Array) to Kotlin ``` open class Uint8Array : ArrayBufferView ``` **Platform and version requirements:** JS (1.1) #### [Uint8ClampedArray](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-uint8-clamped-array/index.html) Exposes the JavaScript [Uint8ClampedArray](https://developer.mozilla.org/en/docs/Web/API/Uint8ClampedArray) to Kotlin ``` open class Uint8ClampedArray : ArrayBufferView ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UIntArray](../-u-int-array/index) ``` class UIntArray : Collection<UInt> ``` **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) #### [ULong](../-u-long/index) ``` class ULong : Comparable<ULong> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [ULongArray](../-u-long-array/index) ``` class ULongArray : Collection<ULong> ``` **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> ``` **Platform and version requirements:** JS (1.1) #### [ULongRange](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-u-long-range/index.html) ``` interface ULongRange ``` **Platform and version requirements:** JS (1.1) #### [UnionAudioTrackOrTextTrackOrVideoTrack](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-audio-track-or-text-track-or-video-track.html) ``` interface UnionAudioTrackOrTextTrackOrVideoTrack ``` **Platform and version requirements:** JS (1.1) #### [UnionClientOrMessagePortOrServiceWorker](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-union-client-or-message-port-or-service-worker.html) ``` interface UnionClientOrMessagePortOrServiceWorker ``` **Platform and version requirements:** JS (1.1) #### [UnionElementOrHTMLCollection](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-element-or-h-t-m-l-collection.html) ``` interface UnionElementOrHTMLCollection ``` **Platform and version requirements:** JS (1.1) #### [UnionElementOrMouseEvent](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-element-or-mouse-event.html) ``` interface UnionElementOrMouseEvent ``` **Platform and version requirements:** JS (1.1) #### [UnionElementOrProcessingInstruction](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.css/-union-element-or-processing-instruction.html) ``` interface UnionElementOrProcessingInstruction ``` **Platform and version requirements:** JS (1.1) #### [UnionElementOrRadioNodeList](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-element-or-radio-node-list.html) ``` interface UnionElementOrRadioNodeList ``` **Platform and version requirements:** JS (1.1) #### [UnionHTMLOptGroupElementOrHTMLOptionElement](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-h-t-m-l-opt-group-element-or-h-t-m-l-option-element.html) ``` interface UnionHTMLOptGroupElementOrHTMLOptionElement ``` **Platform and version requirements:** JS (1.1) #### [UnionMessagePortOrServiceWorker](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.workers/-union-message-port-or-service-worker.html) ``` interface UnionMessagePortOrServiceWorker ``` **Platform and version requirements:** JS (1.1) #### [UnionMessagePortOrWindowProxy](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-union-message-port-or-window-proxy.html) ``` interface UnionMessagePortOrWindowProxy ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Unit](../-unit/index) The type with only one value: the `Unit` object. This type corresponds to the `void` type in Java. ``` object Unit ``` **Platform and version requirements:** Native (1.3) #### [UnsafeNumber](../../kotlinx.cinterop/-unsafe-number/index) Marker for declarations that depend on numeric types of different bit width on at least two platforms. ``` annotation class UnsafeNumber ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [UnsafeVariance](../-unsafe-variance/index) Suppresses errors about variance conflict ``` annotation class UnsafeVariance ``` **Platform and version requirements:** JS (1.1) #### [URL](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.url/-u-r-l/index.html) Exposes the JavaScript [URL](https://developer.mozilla.org/en/docs/Web/API/URL) to Kotlin ``` open class URL ``` **Platform and version requirements:** JS (1.1) #### [URLSearchParams](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.url/-u-r-l-search-params/index.html) Exposes the JavaScript [URLSearchParams](https://developer.mozilla.org/en/docs/Web/API/URLSearchParams) to Kotlin ``` open class URLSearchParams ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UShort](../-u-short/index) ``` class UShort : Comparable<UShort> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [UShortArray](../-u-short-array/index) ``` class UShortArray : Collection<UShort> ``` **Platform and version requirements:** JS (1.1) #### [ValidityState](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-validity-state/index.html) Exposes the JavaScript [ValidityState](https://developer.mozilla.org/en/docs/Web/API/ValidityState) to Kotlin ``` abstract class ValidityState ``` **Platform and version requirements:** Native (1.3) #### [Vector128](../../kotlin.native/-vector128/index) ``` class Vector128 ``` **Platform and version requirements:** JS (1.1) #### [VideoFacingModeEnum](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-video-facing-mode-enum.html) ``` interface VideoFacingModeEnum ``` **Platform and version requirements:** JS (1.1) #### [VideoResizeModeEnum](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.mediacapture/-video-resize-mode-enum.html) ``` interface VideoResizeModeEnum ``` **Platform and version requirements:** JS (1.1) #### [VideoTrack](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-video-track/index.html) Exposes the JavaScript [VideoTrack](https://developer.mozilla.org/en/docs/Web/API/VideoTrack) to Kotlin ``` abstract class VideoTrack :      UnionAudioTrackOrTextTrackOrVideoTrack ``` **Platform and version requirements:** JVM (1.0), JS (1.0) #### [Volatile](../../kotlin.jvm/-volatile/index) Marks the JVM backing field of the annotated property as `volatile`, meaning that writes to this field are immediately made visible to other threads. ``` annotation class Volatile ``` **Platform and version requirements:** Native (1.3) #### [WeakReference](../../kotlin.native.ref/-weak-reference/index) Class WeakReference encapsulates weak reference to an object, which could be used to either retrieve a strong reference to an object, or return null, if object was already destroyed by the memory manager. ``` class WeakReference<T : Any> ``` **Platform and version requirements:** JS (1.1) #### [WebGLActiveInfo](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-active-info/index.html) Exposes the JavaScript [WebGLActiveInfo](https://developer.mozilla.org/en/docs/Web/API/WebGLActiveInfo) to Kotlin ``` abstract class WebGLActiveInfo ``` **Platform and version requirements:** JS (1.1) #### [WebGLContextAttributes](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-context-attributes/index.html) ``` interface WebGLContextAttributes ``` **Platform and version requirements:** JS (1.1) #### [WebGLContextEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-context-event-init/index.html) ``` interface WebGLContextEventInit : EventInit ``` **Platform and version requirements:** JS (1.1) #### [WebGLObject](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-object/index.html) ``` abstract class WebGLObject ``` **Platform and version requirements:** JS (1.1) #### [WebGLRenderingContext](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-rendering-context/index.html) Exposes the JavaScript [WebGLRenderingContext](https://developer.mozilla.org/en/docs/Web/API/WebGLRenderingContext) to Kotlin ``` abstract class WebGLRenderingContext :      WebGLRenderingContextBase,     RenderingContext ``` **Platform and version requirements:** JS (1.1) #### [WebGLRenderingContextBase](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-rendering-context-base/index.html) ``` interface WebGLRenderingContextBase ``` **Platform and version requirements:** JS (1.1) #### [WebGLShaderPrecisionFormat](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-shader-precision-format/index.html) Exposes the JavaScript [WebGLShaderPrecisionFormat](https://developer.mozilla.org/en/docs/Web/API/WebGLShaderPrecisionFormat) to Kotlin ``` abstract class WebGLShaderPrecisionFormat ``` **Platform and version requirements:** JS (1.1) #### [WebGLUniformLocation](https://kotlinlang.org/api/latest/jvm/stdlib/org.khronos.webgl/-web-g-l-uniform-location/index.html) Exposes the JavaScript [WebGLUniformLocation](https://developer.mozilla.org/en/docs/Web/API/WebGLUniformLocation) to Kotlin ``` abstract class WebGLUniformLocation ``` **Platform and version requirements:** JS (1.1) #### [WheelEventInit](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.events/-wheel-event-init/index.html) ``` interface WheelEventInit : MouseEventInit ``` **Platform and version requirements:** JS (1.1) #### [WindowEventHandlers](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-window-event-handlers/index.html) Exposes the JavaScript [WindowEventHandlers](https://developer.mozilla.org/en/docs/Web/API/WindowEventHandlers) to Kotlin ``` interface WindowEventHandlers ``` **Platform and version requirements:** JS (1.1) #### [WindowLocalStorage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-window-local-storage/index.html) Exposes the JavaScript [WindowLocalStorage](https://developer.mozilla.org/en/docs/Web/API/WindowLocalStorage) to Kotlin ``` interface WindowLocalStorage ``` **Platform and version requirements:** JS (1.1) #### [WindowOrWorkerGlobalScope](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-window-or-worker-global-scope/index.html) Exposes the JavaScript [WindowOrWorkerGlobalScope](https://developer.mozilla.org/en/docs/Web/API/WindowOrWorkerGlobalScope) to Kotlin ``` interface WindowOrWorkerGlobalScope ``` **Platform and version requirements:** JS (1.1) #### [WindowSessionStorage](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-window-session-storage/index.html) Exposes the JavaScript [WindowSessionStorage](https://developer.mozilla.org/en/docs/Web/API/WindowSessionStorage) to Kotlin ``` interface WindowSessionStorage ``` **Platform and version requirements:** Native (1.3) #### [Worker](../../kotlin.native.concurrent/-worker/index) ``` class Worker ``` **Platform and version requirements:** Native (1.3) #### [WorkerBoundReference](../../kotlin.native.concurrent/-worker-bound-reference/index) A shared reference to a Kotlin object that doesn't freeze the referred object when it gets frozen itself. ``` class WorkerBoundReference<out T : Any> ``` **Platform and version requirements:** JS (1.1) #### [WorkerLocation](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-worker-location/index.html) Exposes the JavaScript [WorkerLocation](https://developer.mozilla.org/en/docs/Web/API/WorkerLocation) to Kotlin ``` abstract class WorkerLocation ``` **Platform and version requirements:** JS (1.1) #### [WorkerNavigator](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-worker-navigator/index.html) Exposes the JavaScript [WorkerNavigator](https://developer.mozilla.org/en/docs/Web/API/WorkerNavigator) to Kotlin ``` abstract class WorkerNavigator :      NavigatorID,     NavigatorLanguage,     NavigatorOnLine,     NavigatorConcurrentHardware ``` **Platform and version requirements:** JS (1.1) #### [WorkerOptions](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-worker-options/index.html) ``` interface WorkerOptions ``` **Platform and version requirements:** JS (1.1) #### [WorkerType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom/-worker-type.html) ``` interface WorkerType ``` **Platform and version requirements:** JS (1.1) #### [XMLHttpRequestResponseType](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.xhr/-x-m-l-http-request-response-type.html) ``` interface XMLHttpRequestResponseType ``` **Platform and version requirements:** JS (1.1) #### [XMLSerializer](https://kotlinlang.org/api/latest/jvm/stdlib/org.w3c.dom.parsing/-x-m-l-serializer/index.html) Exposes the JavaScript [XMLSerializer](https://developer.mozilla.org/en/docs/Web/API/XMLSerializer) to Kotlin ``` open class XMLSerializer ```
programming_docs
kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Any](index) / [hashCode](hash-code) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open 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](../index) / [Any](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open fun toString(): String ``` Returns a string representation of the object. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Any](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` The root of the Kotlin class hierarchy. Every Kotlin class has [Any](index#kotlin.Any) as a superclass. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Any](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` open operator 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. kotlin IllegalArgumentException IllegalArgumentException ======================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IllegalArgumentException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalArgumentException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalArgumentException = IllegalArgumentException ``` 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> ``` Inheritors ---------- #### [NumberFormatException](../-number-format-exception/index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NumberFormatException : IllegalArgumentException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NumberFormatException = NumberFormatException ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IllegalArgumentException](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) / [Char](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 a Char in a binary form. kotlin MIN_CODE_POINT MIN\_CODE\_POINT ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_CODE\_POINT](-m-i-n_-c-o-d-e_-p-o-i-n-t) **Platform and version requirements:** Native (1.3) ``` const val MIN_CODE_POINT: Int ``` The minimum value of a Unicode code point. Kotlin/Native specific. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toInt(): Int ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Int`. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toByte(): Byte ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Byte`. kotlin Char Char ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Char : Comparable<Char> ``` ##### For Common, JVM, JS Represents a 16-bit Unicode character. On the JVM, non-nullable values of this type are represented as values of the primitive type `char`. ##### For Native Represents a 16-bit Unicode character. Functions --------- **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. ``` fun compareTo(other: Char): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <dec> Returns this value decremented by one. ``` operator fun dec(): Char ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Char): 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(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minus> Subtracts the other Char value from this value resulting an Int. ``` operator fun minus(other: Char): Int ``` Subtracts the other Int value from this value resulting a Char. ``` operator fun minus(other: Int): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <plus> Adds the other Int value to this value resulting a Char. ``` operator fun plus(other: Int): Char ``` **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.Char%24rangeTo(kotlin.Char)/other) value. ``` operator fun rangeTo(other: Char): CharRange ``` **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.Char%24rangeUntil(kotlin.Char)/other) value. ``` operator fun rangeUntil(other: Char): CharRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Returns the value of this character as a `Byte`. ``` fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toChar](to-char) Returns the value of this character as a `Char`. ``` fun toChar(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toDouble](to-double) Returns the value of this character as a `Double`. ``` fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Returns the value of this character as a `Float`. ``` fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Returns the value of this character as a `Int`. ``` fun toInt(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toLong](to-long) Returns the value of this character as a `Long`. ``` fun toLong(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toShort](to-short) Returns the value of this character as a `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 ``` Companion Object Properties --------------------------- **Platform and version requirements:** Native (1.3) #### [MAX\_CODE\_POINT](-m-a-x_-c-o-d-e_-p-o-i-n-t) The maximum value of a Unicode code point. Kotlin/Native specific. ``` const val MAX_CODE_POINT: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_HIGH\_SURROGATE](-m-a-x_-h-i-g-h_-s-u-r-r-o-g-a-t-e) The maximum value of a Unicode high-surrogate code unit. ``` const val MAX_HIGH_SURROGATE: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_LOW\_SURROGATE](-m-a-x_-l-o-w_-s-u-r-r-o-g-a-t-e) The maximum value of a Unicode low-surrogate code unit. ``` const val MAX_LOW_SURROGATE: Char ``` **Platform and version requirements:** Native (1.3) #### [MAX\_RADIX](-m-a-x_-r-a-d-i-x) The maximum radix available for conversion to and from strings. ``` const val MAX_RADIX: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_SURROGATE](-m-a-x_-s-u-r-r-o-g-a-t-e) The maximum value of a Unicode surrogate code unit. ``` const val MAX_SURROGATE: Char ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [MAX\_VALUE](-m-a-x_-v-a-l-u-e) The maximum value of a character code unit. ``` const val MAX_VALUE: Char ``` **Platform and version requirements:** Native (1.3) #### [MIN\_CODE\_POINT](-m-i-n_-c-o-d-e_-p-o-i-n-t) The minimum value of a Unicode code point. Kotlin/Native specific. ``` const val MIN_CODE_POINT: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_HIGH\_SURROGATE](-m-i-n_-h-i-g-h_-s-u-r-r-o-g-a-t-e) The minimum value of a Unicode high-surrogate code unit. ``` const val MIN_HIGH_SURROGATE: Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_LOW\_SURROGATE](-m-i-n_-l-o-w_-s-u-r-r-o-g-a-t-e) The minimum value of a Unicode low-surrogate code unit. ``` const val MIN_LOW_SURROGATE: Char ``` **Platform and version requirements:** Native (1.3) #### [MIN\_RADIX](-m-i-n_-r-a-d-i-x) The minimum radix available for conversion to and from strings. ``` const val MIN_RADIX: Int ``` **Platform and version requirements:** Native (1.3) #### [MIN\_SUPPLEMENTARY\_CODE\_POINT](-m-i-n_-s-u-p-p-l-e-m-e-n-t-a-r-y_-c-o-d-e_-p-o-i-n-t) The minimum value of a supplementary code point, `\u0x10000`. Kotlin/Native specific. ``` const val MIN_SUPPLEMENTARY_CODE_POINT: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MIN\_SURROGATE](-m-i-n_-s-u-r-r-o-g-a-t-e) The minimum value of a Unicode surrogate code unit. ``` const val MIN_SURROGATE: Char ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [MIN\_VALUE](-m-i-n_-v-a-l-u-e) The minimum value of a character code unit. ``` const val MIN_VALUE: Char ``` **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 a Char 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 a Char in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [code](../code) Returns the code of this Char. ``` val Char.code: Int ``` **Platform and version requirements:** JVM (1.0) #### [directionality](../../kotlin.text/directionality) Returns the Unicode directionality property for the given character. ``` val Char.directionality: CharDirectionality ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** JVM (1.5), JS (1.5), Native (1.5) #### [digitToInt](../../kotlin.text/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](../../kotlin.text/digit-to-int#kotlin.text%24digitToInt(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/digit-to-int-or-null#kotlin.text%24digitToIntOrNull(kotlin.Char,%20kotlin.Int)/radix). Throws an exception if the [radix](../../kotlin.text/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) #### [downTo](../../kotlin.ranges/down-to) Returns a progression from this value down to the specified [to](../../kotlin.ranges/down-to#kotlin.ranges%24downTo(kotlin.Char,%20kotlin.Char)/to) value with the step -1. ``` infix fun Char.downTo(to: Char): CharProgression ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [equals](../../kotlin.text/equals) Returns `true` if this character is equal to the [other](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0) #### [isJavaIdentifierPart](../../kotlin.text/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](../../kotlin.text/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), Native (1.0) #### [isSurrogate](../../kotlin.text/is-surrogate) Returns `true` if this character is a Unicode surrogate code unit. ``` fun Char.isSurrogate(): Boolean ``` **Platform and version requirements:** JVM (1.5) #### [lowercase](../../kotlin.text/lowercase) Converts this character to lower case using Unicode mapping rules of the specified [locale](../../kotlin.text/lowercase#kotlin.text%24lowercase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.lowercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [plus](../../kotlin.text/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) #### [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> ``` #### [titlecase](../../kotlin.text/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](../../kotlin.text/titlecase#kotlin.text%24titlecase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.titlecase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0) #### [toTitleCase](../../kotlin.text/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.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.Char,%20kotlin.Char)/to) value. ``` infix fun Char.until(to: Char): CharRange ``` **Platform and version requirements:** JVM (1.5) #### [uppercase](../../kotlin.text/uppercase) Converts this character to upper case using Unicode mapping rules of the specified [locale](../../kotlin.text/uppercase#kotlin.text%24uppercase(kotlin.Char,%20java.util.Locale)/locale). ``` fun Char.uppercase(locale: Locale): String ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](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 a Char in a binary form. kotlin MAX_SURROGATE MAX\_SURROGATE ============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_SURROGATE](-m-a-x_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MAX_SURROGATE: Char ``` The maximum value of a Unicode surrogate code unit. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_VALUE](-m-i-n_-v-a-l-u-e) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` const val MIN_VALUE: Char ``` The minimum value of a character code unit. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toLong(): Long ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Long`. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_VALUE](-m-a-x_-v-a-l-u-e) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` const val MAX_VALUE: Char ``` The maximum value of a character code unit. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun compareTo(other: Char): 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) / [Char](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun rangeTo(other: Char): CharRange ``` Creates a range from this value to the specified [other](range-to#kotlin.Char%24rangeTo(kotlin.Char)/other) value. kotlin rangeUntil rangeUntil ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: Char ): CharRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.Char%24rangeUntil(kotlin.Char)/other) value. If the [other](range-until#kotlin.Char%24rangeUntil(kotlin.Char)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin MAX_CODE_POINT MAX\_CODE\_POINT ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_CODE\_POINT](-m-a-x_-c-o-d-e_-p-o-i-n-t) **Platform and version requirements:** Native (1.3) ``` const val MAX_CODE_POINT: Int ``` The maximum value of a Unicode code point. Kotlin/Native specific. kotlin MIN_SUPPLEMENTARY_CODE_POINT MIN\_SUPPLEMENTARY\_CODE\_POINT =============================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_SUPPLEMENTARY\_CODE\_POINT](-m-i-n_-s-u-p-p-l-e-m-e-n-t-a-r-y_-c-o-d-e_-p-o-i-n-t) **Platform and version requirements:** Native (1.3) ``` const val MIN_SUPPLEMENTARY_CODE_POINT: Int ``` The minimum value of a supplementary code point, `\u0x10000`. Kotlin/Native specific. kotlin MIN_SURROGATE MIN\_SURROGATE ============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_SURROGATE](-m-i-n_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MIN_SURROGATE: Char ``` The minimum value of a Unicode surrogate code unit. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toDouble(): Double ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Double`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Char ``` 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) / [Char](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) / [Char](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Char ``` 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 MIN_LOW_SURROGATE MIN\_LOW\_SURROGATE =================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_LOW\_SURROGATE](-m-i-n_-l-o-w_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MIN_LOW_SURROGATE: Char ``` The minimum value of a Unicode low-surrogate code unit. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](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 MAX_HIGH_SURROGATE MAX\_HIGH\_SURROGATE ==================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_HIGH\_SURROGATE](-m-a-x_-h-i-g-h_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MAX_HIGH_SURROGATE: Char ``` The maximum value of a Unicode high-surrogate code unit. kotlin MAX_LOW_SURROGATE MAX\_LOW\_SURROGATE =================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_LOW\_SURROGATE](-m-a-x_-l-o-w_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MAX_LOW_SURROGATE: Char ``` The maximum value of a Unicode low-surrogate code unit. kotlin MIN_RADIX MIN\_RADIX ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_RADIX](-m-i-n_-r-a-d-i-x) **Platform and version requirements:** Native (1.3) ``` const val MIN_RADIX: Int ``` The minimum radix available for conversion to and from strings. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](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: Char): Boolean ``` kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toFloat(): Float ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Float`. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Char): Int ``` Subtracts the other Char value from this value resulting an Int. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Int): Char ``` Subtracts the other Int value from this value resulting a Char. kotlin MAX_RADIX MAX\_RADIX ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MAX\_RADIX](-m-a-x_-r-a-d-i-x) **Platform and version requirements:** Native (1.3) ``` const val MAX_RADIX: Int ``` The maximum radix available for conversion to and from strings. kotlin MIN_HIGH_SURROGATE MIN\_HIGH\_SURROGATE ==================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [MIN\_HIGH\_SURROGATE](-m-i-n_-h-i-g-h_-s-u-r-r-o-g-a-t-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val MIN_HIGH_SURROGATE: Char ``` The minimum value of a Unicode high-surrogate code unit. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.5") fun toShort(): Short ``` **Deprecated:** Conversion of Char to Number is deprecated. Use Char.code property instead. Returns the value of this character as a `Short`. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun plus(other: Int): Char ``` Adds the other Int value to this value resulting a Char. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Char](index) / [toChar](to-char) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toChar(): Char ``` Returns the value of this character as a `Char`. kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin ShortArray ShortArray ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class ShortArray ``` ##### For Common, JVM, JS An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`. ##### For Native An array of shorts. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Short) ``` Creates a new array of the specified [size](size#kotlin.ShortArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.ShortArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Short ``` **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(): ShortIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/index) to the given [value](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Short) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val ShortArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val ShortArray.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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.all(predicate: (Short) -> 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 ShortArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.any(predicate: (Short) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun ShortArray.asIterable(): Iterable<Short> ``` **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 array returning its elements when being iterated. ``` fun ShortArray.asSequence(): Sequence<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> ShortArray.associate(     transform: (Short) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> ShortArray.associateBy(     keySelector: (Short) -> K ): Map<K, Short> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> ShortArray.associateBy(     keySelector: (Short) -> K,     valueTransform: (Short) -> 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.ShortArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Short>> ShortArray.associateByTo(     destination: M,     keySelector: (Short) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.ShortArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.ShortArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateByTo(     destination: M,     keySelector: (Short) -> K,     valueTransform: (Short) -> 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.ShortArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> ShortArray.associateTo(     destination: M,     transform: (Short) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> ShortArray.associateWith(     valueSelector: (Short) -> V ): Map<Short, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.ShortArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Short, in V>> ShortArray.associateWithTo(     destination: M,     valueSelector: (Short) -> V ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUShortArray](../../kotlin.collections/as-u-short-array) Returns an array of type [UShortArray](../-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](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun ShortArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.ShortArray,%20kotlin.Short,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun ShortArray.binarySearch(     element: Short,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun ShortArray.component1(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun ShortArray.component2(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun ShortArray.component3(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun ShortArray.component4(): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun ShortArray.component5(): Short ``` **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.ShortArray,%20kotlin.Short)/element) is found in the array. ``` operator fun ShortArray.contains(element: Short): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun ShortArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.count(predicate: (Short) -> 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 array. ``` fun ShortArray.distinct(): List<Short> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> ShortArray.distinctBy(     selector: (Short) -> K ): List<Short> ``` **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.ShortArray,%20kotlin.Int)/n) elements. ``` fun ShortArray.drop(n: Int): List<Short> ``` **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.ShortArray,%20kotlin.Int)/n) elements. ``` fun ShortArray.dropLast(n: Int): List<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.dropLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.dropWhile(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/index) is out of bounds of this array. ``` fun ShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ShortArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ShortArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ShortArray.elementAtOrNull(index: Int): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.filter(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.filterIndexed(     predicate: (index: Int, Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.ShortArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Short>> ShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Short) -> Boolean ): 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.filterNot(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.ShortArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Short>> ShortArray.filterNotTo(     destination: C,     predicate: (Short) -> 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.ShortArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.ShortArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Short>> ShortArray.filterTo(     destination: C,     predicate: (Short) -> 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ShortArray.find(predicate: (Short) -> Boolean): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ShortArray.findLast(     predicate: (Short) -> Boolean ): Short? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun ShortArray.first(): Short ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.first(predicate: (Short) -> Boolean): Short ``` **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 ShortArray.firstOrNull(): Short? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun ShortArray.firstOrNull(     predicate: (Short) -> Boolean ): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> ShortArray.flatMap(     transform: (Short) -> Iterable<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.ShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> ShortArray.flatMapIndexed(     transform: (index: Int, Short) -> Iterable<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.ShortArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%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.ShortArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ShortArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Short) -> Iterable<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.ShortArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ShortArray.flatMapTo(     destination: C,     transform: (Short) -> Iterable<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.ShortArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Short,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.ShortArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Short,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> ShortArray.fold(     initial: R,     operation: (acc: R, Short) -> 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.ShortArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Short,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.ShortArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Short,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> ShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> 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.ShortArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Short,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.ShortArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Short,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> ShortArray.foldRight(     initial: R,     operation: (Short, 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.ShortArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.ShortArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%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> ShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, Short, 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Unit)))/action) on each element. ``` fun ShortArray.forEach(action: (Short) -> 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.ShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun ShortArray.forEachIndexed(     action: (index: Int, Short) -> 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.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Short)))/index) is out of bounds of this array. ``` fun ShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> Short ): Short ``` **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.ShortArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.ShortArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ShortArray.getOrNull(index: Int): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%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> ShortArray.groupBy(     keySelector: (Short) -> K ): Map<K, List<Short>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Short,%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> ShortArray.groupBy(     keySelector: (Short) -> K,     valueTransform: (Short) -> 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.ShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Short>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Short,%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>>> ShortArray.groupByTo(     destination: M,     keySelector: (Short) -> K,     valueTransform: (Short) -> V ): M ``` **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.ShortArray,%20kotlin.Short)/element), or -1 if the array does not contain element. ``` fun ShortArray.indexOf(element: Short): 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ShortArray.indexOfFirst(     predicate: (Short) -> 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ShortArray.indexOfLast(     predicate: (Short) -> 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 array and the specified collection. ``` infix fun ShortArray.intersect(     other: Iterable<Short> ): Set<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun ShortArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun ShortArray.isNotEmpty(): 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.ShortArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.ShortArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.ShortArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> ShortArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> 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.ShortArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.ShortArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.ShortArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Short,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun ShortArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Short) -> 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 ShortArray.last(): Short ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.last(predicate: (Short) -> Boolean): Short ``` **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.ShortArray,%20kotlin.Short)/element), or -1 if the array does not contain element. ``` fun ShortArray.lastIndexOf(element: Short): 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 ShortArray.lastOrNull(): Short? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ShortArray.lastOrNull(     predicate: (Short) -> Boolean ): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> ShortArray.map(transform: (Short) -> 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.ShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> ShortArray.mapIndexed(     transform: (index: Int, Short) -> R ): List<R> ``` **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.ShortArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%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.ShortArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, Short) -> 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.ShortArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Short,%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.ShortArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ShortArray.mapTo(     destination: C,     transform: (Short) -> 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>> ShortArray.maxByOrNull(     selector: (Short) -> R ): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Short) -> 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Short) -> 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.ShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.ShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Short) -> 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.ShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.ShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> 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 ShortArray.maxOrNull(): Short? ``` #### [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.ShortArray,%20kotlin.Comparator((kotlin.Short)))/comparator). ``` fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun ShortArray.maxWith(     comparator: Comparator<in Short> ): Short? ``` **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.ShortArray,%20kotlin.Comparator((kotlin.Short)))/comparator) or `null` if there are no elements. ``` fun ShortArray.maxWithOrNull(     comparator: Comparator<in Short> ): Short? ``` **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>> ShortArray.minByOrNull(     selector: (Short) -> R ): Short? ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Short) -> 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Short) -> 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.ShortArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.ShortArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (Short) -> 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.ShortArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.ShortArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Short,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Short) -> 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 ShortArray.minOrNull(): Short? ``` #### [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.ShortArray,%20kotlin.Comparator((kotlin.Short)))/comparator). ``` fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short ``` **Platform and version requirements:** JVM (1.0) ``` fun ShortArray.minWith(     comparator: Comparator<in Short> ): Short? ``` **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.ShortArray,%20kotlin.Comparator((kotlin.Short)))/comparator) or `null` if there are no elements. ``` fun ShortArray.minWithOrNull(     comparator: Comparator<in Short> ): Short? ``` **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 ShortArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.none(predicate: (Short) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun ShortArray.onEach(action: (Short) -> Unit): ShortArray ``` **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.ShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Short,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun ShortArray.onEachIndexed(     action: (index: Int, Short) -> Unit ): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun ShortArray.partition(     predicate: (Short) -> Boolean ): Pair<List<Short>, List<Short>> ``` **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 ShortArray.random(): Short ``` Returns a random element from this array using the specified source of randomness. ``` fun ShortArray.random(random: Random): Short ``` **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 ShortArray.randomOrNull(): Short? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun ShortArray.randomOrNull(random: Random): Short? ``` **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.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ShortArray.reduce(     operation: (acc: Short, Short) -> Short ): Short ``` **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.ShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ShortArray.reduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): Short ``` **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.ShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: Short, Short) -> Short ): Short? ``` **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.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ShortArray.reduceOrNull(     operation: (acc: Short, Short) -> Short ): Short? ``` **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.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ShortArray.reduceRight(     operation: (Short, acc: Short) -> Short ): Short ``` **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.ShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ShortArray.reduceRightIndexed(     operation: (index: Int, Short, acc: Short) -> Short ): Short ``` **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.ShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ShortArray.reduceRightIndexedOrNull(     operation: (index: Int, Short, acc: Short) -> Short ): Short? ``` **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.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ShortArray.reduceRightOrNull(     operation: (Short, acc: Short) -> Short ): Short? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun ShortArray.refTo(index: Int): CValuesRef<ShortVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun ShortArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun ShortArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 ShortArray.reversed(): List<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun ShortArray.reversedArray(): ShortArray ``` **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.ShortArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Short,%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.ShortArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Short,%20)))/initial) value. ``` fun <R> ShortArray.runningFold(     initial: R,     operation: (acc: R, Short) -> 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.ShortArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Short,%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.ShortArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Short,%20)))/initial) value. ``` fun <R> ShortArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> 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.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun ShortArray.runningReduce(     operation: (acc: Short, Short) -> Short ): List<Short> ``` **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.ShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Short,%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 ShortArray.runningReduceIndexed(     operation: (index: Int, acc: Short, Short) -> Short ): List<Short> ``` **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.ShortArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Short,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.ShortArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Short,%20)))/initial) value. ``` fun <R> ShortArray.scan(     initial: R,     operation: (acc: R, Short) -> 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.ShortArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Short,%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.ShortArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Short,%20)))/initial) value. ``` fun <R> ShortArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Short) -> 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 ShortArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.ShortArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun ShortArray.shuffle(random: Random) ``` **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 ShortArray.single(): Short ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun ShortArray.single(predicate: (Short) -> Boolean): Short ``` **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 ShortArray.singleOrNull(): Short? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun ShortArray.singleOrNull(     predicate: (Short) -> Boolean ): Short? ``` **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.ShortArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ShortArray.slice(indices: IntRange): List<Short> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.ShortArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun ShortArray.slice(indices: Iterable<Int>): List<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ShortArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun ShortArray.sliceArray(     indices: Collection<Int> ): ShortArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ShortArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ShortArray.sliceArray(indices: IntRange): ShortArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20kotlin.Int)))/comparison) function. ``` fun ShortArray.sort(comparison: (a: Short, b: Short) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun ShortArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun ShortArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun ShortArray.sorted(): List<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun ShortArray.sortedArray(): ShortArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun ShortArray.sortedArrayDescending(): ShortArray ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> ShortArray.sortedBy(     selector: (Short) -> R? ): List<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> ShortArray.sortedByDescending(     selector: (Short) -> R? ): List<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun ShortArray.sortedDescending(): List<Short> ``` **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.ShortArray,%20kotlin.Comparator((kotlin.Short)))/comparator). ``` fun ShortArray.sortedWith(     comparator: Comparator<in Short> ): List<Short> ``` **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 array and not contained by the specified collection. ``` infix fun ShortArray.subtract(     other: Iterable<Short> ): Set<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun ShortArray.sum(): Int ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun ShortArray.sumBy(selector: (Short) -> 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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun ShortArray.sumByDouble(     selector: (Short) -> Double ): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.ShortArray,%20kotlin.Function1((kotlin.Short,%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 ShortArray.sumOf(selector: (Short) -> Double): Double ``` **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 ShortArray.sumOf(selector: (Short) -> Long): Long ``` **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 ShortArray.sumOf(selector: (Short) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun ShortArray.sumOf(     selector: (Short) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ShortArray.sumOf(     selector: (Short) -> BigInteger ): BigInteger ``` **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.ShortArray,%20kotlin.Int)/n) elements. ``` fun ShortArray.take(n: Int): List<Short> ``` **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.ShortArray,%20kotlin.Int)/n) elements. ``` fun ShortArray.takeLast(n: Int): List<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.takeLastWhile(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.Function1((kotlin.Short,%20kotlin.Boolean)))/predicate). ``` fun ShortArray.takeWhile(     predicate: (Short) -> Boolean ): List<Short> ``` **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.ShortArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Short>> ShortArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun ShortArray.toCValues(): CValues<ShortVar> ``` **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 ShortArray.toHashSet(): HashSet<Short> ``` **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 ShortArray.toList(): List<Short> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun ShortArray.toMutableList(): MutableList<Short> ``` **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 array. ``` fun ShortArray.toMutableSet(): MutableSet<Short> ``` **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 ShortArray.toSet(): Set<Short> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun ShortArray.toSortedSet(): SortedSet<Short> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../../kotlin.collections/to-u-short-array) Returns an array of type [UShortArray](../-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 ``` **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 ShortArray.union(     other: Iterable<Short> ): Set<Short> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun ShortArray.withIndex(): Iterable<IndexedValue<Short>> ``` **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.ShortArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Short, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ShortArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Short,%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.ShortArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Short,%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> ShortArray.zip(     other: Array<out R>,     transform: (a: Short, 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.ShortArray,%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> ShortArray.zip(     other: Iterable<R> ): List<Pair<Short, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ShortArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Short,%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.ShortArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Short,%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> ShortArray.zip(     other: Iterable<R>,     transform: (a: Short, 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.ShortArray,%20kotlin.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ShortArray,%20kotlin.ShortArray,%20kotlin.Function2((kotlin.Short,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> ShortArray.zip(     other: ShortArray,     transform: (a: Short, b: Short) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): ShortIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Short) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.ShortArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.ShortArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Short) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/index) to the given [value](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/value). This method can be called using the index operator. If the [index](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/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. ##### For Native Sets the element at the given [index](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/index) to the given [value](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/value). This method can be called using the index operator. If the [index](set#kotlin.ShortArray%24set(kotlin.Int,%20kotlin.Short)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ShortArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Short ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.ShortArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.ShortArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.ShortArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.ShortArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin DeepRecursiveFunction DeepRecursiveFunction ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeepRecursiveFunction](index) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` class DeepRecursiveFunction<T, R> ``` Defines deep recursive function that keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack. To initiate a call to this deep recursive function use its [invoke](../invoke) function. As a rule of thumb, it should be used if recursion goes deeper than a thousand calls. The [DeepRecursiveFunction](index) takes one parameter of type [T](index#T) and returns a result of type [R](index#R). The block of code defines the body of a recursive function. In this block [callRecursive](../-deep-recursive-scope/call-recursive) function can be used to make a recursive call to the declared function. Other instances of [DeepRecursiveFunction](index) can be called in this scope with `callRecursive` extension, too. For example, take a look at the following recursive tree class and a deeply recursive instance of this tree with 100K nodes: ``` class Tree(val left: Tree? = null, val right: Tree? = null) val deepTree = generateSequence(Tree()) { Tree(it) }.take(100_000).last() ``` A regular recursive function can be defined to compute a depth of a tree: ``` fun depth(t: Tree?): Int = if (t == null) 0 else max(depth(t.left), depth(t.right)) + 1 println(depth(deepTree)) // StackOverflowError ``` If this `depth` function is called for a `deepTree` it produces `StackOverflowError` because of deep recursion. However, the `depth` function can be rewritten using `DeepRecursiveFunction` in the following way, and then it successfully computes [`depth(deepTree)`](../invoke) expression: ``` val depth = DeepRecursiveFunction<Tree?, Int> { t -> if (t == null) 0 else max(callRecursive(t.left), callRecursive(t.right)) + 1 } println(depth(deepTree)) // Ok ``` Deep recursive functions can also mutually call each other using a heap for the stack via [callRecursive](../-deep-recursive-scope/call-recursive) extension. For example, the following pair of mutually recursive functions computes the number of tree nodes at even depth in the tree. ``` val mutualRecursion = object { val even: DeepRecursiveFunction<Tree?, Int> = DeepRecursiveFunction { t -> if (t == null) 0 else odd.callRecursive(t.left) + odd.callRecursive(t.right) + 1 } val odd: DeepRecursiveFunction<Tree?, Int> = DeepRecursiveFunction { t -> if (t == null) 0 else even.callRecursive(t.left) + even.callRecursive(t.right) } } ``` Parameters ---------- `T` - the function parameter type. `R` - the function result type. `block` - the function body. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Defines deep recursive function that keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack. To initiate a call to this deep recursive function use its [invoke](../invoke) function. As a rule of thumb, it should be used if recursion goes deeper than a thousand calls. ``` DeepRecursiveFunction(     block: suspend DeepRecursiveScope<T, R>.(T) -> R) ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) #### [invoke](../invoke) Initiates a call to this deep recursive function, forming a root of the call tree. ``` operator fun <T, R> DeepRecursiveFunction<T, R>.invoke(     value: T ): R ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeepRecursiveFunction](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` DeepRecursiveFunction(     block: suspend DeepRecursiveScope<T, R>.(T) -> R) ``` Defines deep recursive function that keeps its stack on the heap, which allows very deep recursive computations that do not use the actual call stack. To initiate a call to this deep recursive function use its [invoke](../invoke) function. As a rule of thumb, it should be used if recursion goes deeper than a thousand calls. The [DeepRecursiveFunction](index) takes one parameter of type [T](index#T) and returns a result of type [R](index#R). The block of code defines the body of a recursive function. In this block [callRecursive](../-deep-recursive-scope/call-recursive) function can be used to make a recursive call to the declared function. Other instances of [DeepRecursiveFunction](index) can be called in this scope with `callRecursive` extension, too. For example, take a look at the following recursive tree class and a deeply recursive instance of this tree with 100K nodes: ``` class Tree(val left: Tree? = null, val right: Tree? = null) val deepTree = generateSequence(Tree()) { Tree(it) }.take(100_000).last() ``` A regular recursive function can be defined to compute a depth of a tree: ``` fun depth(t: Tree?): Int = if (t == null) 0 else max(depth(t.left), depth(t.right)) + 1 println(depth(deepTree)) // StackOverflowError ``` If this `depth` function is called for a `deepTree` it produces `StackOverflowError` because of deep recursion. However, the `depth` function can be rewritten using `DeepRecursiveFunction` in the following way, and then it successfully computes [`depth(deepTree)`](../invoke) expression: ``` val depth = DeepRecursiveFunction<Tree?, Int> { t -> if (t == null) 0 else max(callRecursive(t.left), callRecursive(t.right)) + 1 } println(depth(deepTree)) // Ok ``` Deep recursive functions can also mutually call each other using a heap for the stack via [callRecursive](../-deep-recursive-scope/call-recursive) extension. For example, the following pair of mutually recursive functions computes the number of tree nodes at even depth in the tree. ``` val mutualRecursion = object { val even: DeepRecursiveFunction<Tree?, Int> = DeepRecursiveFunction { t -> if (t == null) 0 else odd.callRecursive(t.left) + odd.callRecursive(t.right) + 1 } val odd: DeepRecursiveFunction<Tree?, Int> = DeepRecursiveFunction { t -> if (t == null) 0 else even.callRecursive(t.left) + even.callRecursive(t.right) } } ``` Parameters ---------- `T` - the function parameter type. `R` - the function result type. `block` - the function body. kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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 ULong in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toInt(): Int ``` Converts this [ULong](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 `ULong`. The resulting `Int` value is represented by the least significant 32 bits of this `ULong` value. Note that the resulting `Int` value may be negative. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toByte(): Byte ``` Converts this [ULong](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 `ULong`. The resulting `Byte` value is represented by the least significant 8 bits of this `ULong` value. Note that the resulting `Byte` value may be negative. kotlin shr shr === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <shr> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun shr(bitCount: Int): ULong ``` Shifts this value right by the [bitCount](shr#kotlin.ULong%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. Note that only the six lowest-order bits of the [bitCount](shr#kotlin.ULong%24shr(kotlin.Int)/bitCount) are used as the shift distance. The shift distance actually used is therefore always in the range `0..63`. kotlin ULong ULong ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline class ULong : Comparable<ULong> ``` 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: ULong): ULong ``` **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(): ULong ``` **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): ULong ``` ``` operator fun div(other: UShort): ULong ``` ``` operator fun div(other: UInt): ULong ``` ``` 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): ULong ``` ``` fun floorDiv(other: UShort): ULong ``` ``` fun floorDiv(other: UInt): ULong ``` ``` 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(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): ULong ``` **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): ULong ``` ``` operator fun minus(other: UShort): ULong ``` ``` operator fun minus(other: UInt): ULong ``` ``` 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: ULong): ULong ``` **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): ULong ``` ``` operator fun plus(other: UShort): ULong ``` ``` operator fun plus(other: UInt): ULong ``` ``` 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.ULong%24rangeTo(kotlin.ULong)/other) value. ``` operator fun rangeTo(other: ULong): ULongRange ``` **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.ULong%24rangeUntil(kotlin.ULong)/other) value. ``` operator fun rangeUntil(other: ULong): ULongRange ``` **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): ULong ``` ``` operator fun rem(other: UShort): ULong ``` ``` operator fun rem(other: UInt): ULong ``` ``` 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.ULong%24shl(kotlin.Int)/bitCount) number of bits. ``` infix fun shl(bitCount: Int): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <shr> Shifts this value right by the [bitCount](shr#kotlin.ULong%24shr(kotlin.Int)/bitCount) number of bits, filling the leftmost bits with zeros. ``` infix fun shr(bitCount: Int): 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): ULong ``` ``` operator fun times(other: UShort): ULong ``` ``` operator fun times(other: UInt): ULong ``` ``` operator fun times(other: ULong): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [ULong](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 [ULong](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 [ULong](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 [ULong](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 [ULong](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 [ULong](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 [ULong](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 [ULong](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) Returns this value. ``` fun toULong(): ULong ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUShort](to-u-short) Converts this [ULong](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: ULong): ULong ``` 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 ULong can have. ``` const val MAX_VALUE: ULong ``` **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 ULong can have. ``` const val MIN_VALUE: ULong ``` **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 ULong 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 ULong 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.ULong,%20kotlin.ULong)/minimumValue). ``` fun ULong.coerceAtLeast(minimumValue: ULong): ULong ``` ``` 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.ULong,%20kotlin.ULong)/maximumValue). ``` fun ULong.coerceAtMost(maximumValue: ULong): ULong ``` ``` 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.ULong,%20kotlin.ULong,%20kotlin.ULong)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ULong,%20kotlin.ULong,%20kotlin.ULong)/maximumValue). ``` fun ULong.coerceIn(     minimumValue: ULong,     maximumValue: ULong ): ULong ``` ``` 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.ULong,%20kotlin.ranges.ClosedRange((kotlin.ULong)))/range). ``` fun ULong.coerceIn(range: ClosedRange<ULong>): ULong ``` ``` 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> ULong.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 [ULong](index) number. ``` fun ULong.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 [ULong](index) number. ``` fun ULong.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 [ULong](index) number. ``` fun ULong.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.ULong,%20kotlin.ULong)/to) value with the step -1. ``` infix fun ULong.downTo(to: ULong): ULongProgression ``` **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 [ULong](index) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.ULong,%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 ULong.rotateLeft(bitCount: Int): ULong ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [ULong](index) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.ULong,%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 ULong.rotateRight(bitCount: Int): ULong ``` **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 [ULong](index) number, or zero, if this number is zero. ``` fun ULong.takeHighestOneBit(): ULong ``` **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 [ULong](index) number, or zero, if this number is zero. ``` fun ULong.takeLowestOneBit(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toString](../../kotlin.text/to-string) Returns a string representation of this [Long](../-long/index#kotlin.Long) value in the specified [radix](../../kotlin.text/to-string#kotlin.text%24toString(kotlin.ULong,%20kotlin.Int)/radix). ``` fun ULong.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.ULong,%20kotlin.ULong)/to) value. ``` infix fun ULong.until(to: ULong): ULongRange ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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 ULong in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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: ULong ``` A constant holding the minimum value an instance of ULong can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toLong(): Long ``` Converts this [ULong](index) value to [Long](../-long/index#kotlin.Long). If this value is less than or equals to [Long.MAX\_VALUE](../-long/-m-a-x_-v-a-l-u-e#kotlin.Long.Companion%24MAX_VALUE), the resulting `Long` value represents the same numerical value as this `ULong`. Otherwise the result is negative. The resulting `Long` value has the same binary representation as this `ULong` value. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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: ULong ``` A constant holding the maximum value an instance of ULong can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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) / [ULong](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: ULong): ULongRange ``` Creates a range from this value to the specified [other](range-to#kotlin.ULong%24rangeTo(kotlin.ULong)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <rem> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rem(other: UByte): ULong ``` ``` operator fun rem(other: UShort): ULong ``` ``` operator fun rem(other: UInt): ULong ``` ``` 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) / [ULong](index) / <shl> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun shl(bitCount: Int): ULong ``` Shifts this value left by the [bitCount](shl#kotlin.ULong%24shl(kotlin.Int)/bitCount) number of bits. Note that only the six lowest-order bits of the [bitCount](shl#kotlin.ULong%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) / [ULong](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: ULong ): ULongRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.ULong%24rangeUntil(kotlin.ULong)/other) value. If the [other](range-until#kotlin.ULong%24rangeUntil(kotlin.ULong)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: UByte): ULong ``` ``` operator fun div(other: UShort): ULong ``` ``` operator fun div(other: UInt): ULong ``` ``` 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) / [ULong](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toDouble(): Double ``` Converts this [ULong](index) value to [Double](../-double/index#kotlin.Double). The resulting value is the closest `Double` to this `ULong` value. In case when this `ULong` 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) / [ULong](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun dec(): ULong ``` 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) / [ULong](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun and(other: ULong): ULong ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun inc(): ULong ``` 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) / [ULong](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun inv(): ULong ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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) / [ULong](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUInt(): UInt ``` Converts this [ULong](index) value to [UInt](../-u-int/index). If this value is less than or equals to [UInt.MAX\_VALUE](../-u-int/-m-a-x_-v-a-l-u-e), the resulting `UInt` value represents the same numerical value as this `ULong`. The resulting `UInt` value is represented by the least significant 32 bits of this `ULong` value. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun xor(other: ULong): ULong ``` Performs a bitwise XOR operation between the two values. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: UByte): ULong ``` ``` operator fun times(other: UShort): ULong ``` ``` operator fun times(other: UInt): ULong ``` ``` operator fun times(other: ULong): ULong ``` Multiplies this value by the other value. kotlin mod mod === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](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) / [ULong](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toFloat(): Float ``` Converts this [ULong](index) value to [Float](../-float/index#kotlin.Float). The resulting value is the closest `Float` to this `ULong` value. In case when this `ULong` 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) / [ULong](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: UByte): ULong ``` ``` operator fun minus(other: UShort): ULong ``` ``` operator fun minus(other: UInt): ULong ``` ``` operator fun minus(other: ULong): ULong ``` Subtracts the other value from this value. kotlin toUByte toUByte ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toUByte](to-u-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUByte(): UByte ``` Converts this [ULong](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 `ULong`. The resulting `UByte` value is represented by the least significant 8 bits of this `ULong` value. kotlin floorDiv floorDiv ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [floorDiv](floor-div) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun floorDiv(other: UByte): ULong ``` ``` fun floorDiv(other: UShort): ULong ``` ``` fun floorDiv(other: UInt): ULong ``` ``` 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) / [ULong](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toShort(): Short ``` Converts this [ULong](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 `ULong`. The resulting `Short` value is represented by the least significant 16 bits of this `ULong` value. Note that the resulting `Short` value may be negative. kotlin toULong toULong ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toULong](to-u-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toULong(): ULong ``` Returns this value. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: UByte): ULong ``` ``` operator fun plus(other: UShort): ULong ``` ``` operator fun plus(other: UInt): ULong ``` ``` operator fun plus(other: ULong): ULong ``` Adds the other value to this value. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun or(other: ULong): ULong ``` Performs a bitwise OR operation between the two values. kotlin toUShort toUShort ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ULong](index) / [toUShort](to-u-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUShort(): UShort ``` Converts this [ULong](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 `ULong`. The resulting `UShort` value is represented by the least significant 16 bits of this `ULong` value. kotlin Suppress Suppress ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Suppress](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([AnnotationTarget.CLASS, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.TYPE_PARAMETER, AnnotationTarget.PROPERTY, AnnotationTarget.FIELD, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.TYPE, AnnotationTarget.EXPRESSION, AnnotationTarget.FILE, AnnotationTarget.TYPEALIAS]) annotation class Suppress ``` Suppresses the given compilation warnings in the annotated element. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Suppresses the given compilation warnings in the annotated element. ``` <init>(vararg names: String) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <names> names of the compiler diagnostics to suppress. ``` vararg val names: Array<out String> ``` 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 names names ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Suppress](index) / <names> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` vararg val names: Array<out String> ``` names of the compiler diagnostics to suppress. Property -------- `names` - names of the compiler diagnostics to suppress. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Suppress](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(vararg names: String) ``` Suppresses the given compilation warnings in the annotated element. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(element: UByte): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](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 UByteArray UByteArray ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline class UByteArray :      Collection<UByte> ``` 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. ``` UByteArray(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: UByte): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<UByte>): 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.UByteArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): UByte ``` **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<UByte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.UByteArray%24set(kotlin.Int,%20kotlin.UByte)/index) to the given [value](set#kotlin.UByteArray%24set(kotlin.Int,%20kotlin.UByte)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: UByte) ``` 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 UByteArray.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 UByteArray.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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.all(predicate: (UByte) -> 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 UByteArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.any(predicate: (UByte) -> Boolean): Boolean ``` ``` fun <T> Iterable<T>.any(predicate: (T) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asByteArray](../../kotlin.collections/as-byte-array) Returns an array of type [ByteArray](../-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.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) #### [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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> UByteArray.associateWith(     valueSelector: (UByte) -> V ): Map<UByte, 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.UByteArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UByte,%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.UByteArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in UByte, in V>> UByteArray.associateWithTo(     destination: M,     valueSelector: (UByte) -> 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.UByteArray,%20kotlin.UByte,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun UByteArray.binarySearch(     element: UByte,     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 UByteArray.component1(): UByte ``` **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 UByteArray.component2(): UByte ``` **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 UByteArray.component3(): UByte ``` **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 UByteArray.component4(): UByte ``` **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 UByteArray.component5(): UByte ``` **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 UByteArray.contentEquals(     other: UByteArray ): Boolean ``` ``` infix fun UByteArray?.contentEquals(     other: UByteArray? ): 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 UByteArray.contentHashCode(): Int ``` ``` fun UByteArray?.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 UByteArray.contentToString(): String ``` ``` fun UByteArray?.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.UByteArray,%20kotlin.UByteArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. ``` fun UByteArray.copyInto(     destination: UByteArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UByteArray ``` **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 UByteArray.copyOf(): UByteArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](../../kotlin.collections/copy-of#kotlin.collections%24copyOf(kotlin.UByteArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. ``` fun UByteArray.copyOf(newSize: Int): UByteArray ``` **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 UByteArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UByteArray ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.count(predicate: (UByte) -> 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.UByteArray,%20kotlin.Int)/n) elements. ``` fun UByteArray.drop(n: Int): List<UByte> ``` **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.UByteArray,%20kotlin.Int)/n) elements. ``` fun UByteArray.dropLast(n: Int): List<UByte> ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.dropLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.dropWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` 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.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/index) is out of bounds of this array. ``` fun UByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` 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.UByteArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.UByteArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UByteArray.elementAtOrNull(index: Int): UByte? ``` **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.UByteArray,%20kotlin.UByte,%20kotlin.Int,%20kotlin.Int)/element) value. ``` fun UByteArray.fill(     element: UByte,     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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.filter(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` 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.UByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.filterIndexed(     predicate: (index: Int, UByte) -> Boolean ): List<UByte> ``` ``` 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.UByteArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.UByteArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UByte>> UByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.filterNot(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` 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.UByteArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.UByteArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UByte>> UByteArray.filterNotTo(     destination: C,     predicate: (UByte) -> 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.UByteArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.UByteArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UByte>> UByteArray.filterTo(     destination: C,     predicate: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UByteArray.find(predicate: (UByte) -> Boolean): UByte? ``` ``` 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UByteArray.findLast(     predicate: (UByte) -> Boolean ): UByte? ``` ``` 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 UByteArray.first(): UByte ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.first(predicate: (UByte) -> Boolean): UByte ``` ``` 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 UByteArray.firstOrNull(): UByte? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun UByteArray.firstOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> UByteArray.flatMap(     transform: (UByte) -> 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.UByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> UByteArray.flatMapIndexed(     transform: (index: Int, UByte) -> 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.UByteArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%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.UByteArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> UByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> 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.UByteArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UByte,%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.UByteArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> UByteArray.flatMapTo(     destination: C,     transform: (UByte) -> 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.UByteArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UByte,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.UByteArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UByte,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> UByteArray.fold(     initial: R,     operation: (acc: R, UByte) -> 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.UByteArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UByte,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.UByteArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UByte,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> UByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> 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.UByteArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UByte,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.UByteArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UByte,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> UByteArray.foldRight(     initial: R,     operation: (UByte, 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.UByteArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.UByteArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%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> UByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, UByte, 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Unit)))/action) on each element. ``` fun UByteArray.forEach(action: (UByte) -> 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.UByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun UByteArray.forEachIndexed(     action: (index: Int, UByte) -> 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.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UByte)))/index) is out of bounds of this array. ``` fun UByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> UByte ): UByte ``` **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.UByteArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.UByteArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UByteArray.getOrNull(index: Int): UByte? ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%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> UByteArray.groupBy(     keySelector: (UByte) -> K ): Map<K, List<UByte>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UByte,%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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UByte,%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> UByteArray.groupBy(     keySelector: (UByte) -> K,     valueTransform: (UByte) -> 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.UByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<UByte>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UByte,%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.UByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UByte,%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>>> UByteArray.groupByTo(     destination: M,     keySelector: (UByte) -> K,     valueTransform: (UByte) -> 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.UByteArray,%20kotlin.UByte)/element), or -1 if the array does not contain element. ``` fun UByteArray.indexOf(element: UByte): 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UByteArray.indexOfFirst(     predicate: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UByteArray.indexOfLast(     predicate: (UByte) -> 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 UByteArray.last(): UByte ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.last(predicate: (UByte) -> Boolean): UByte ``` ``` 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.UByteArray,%20kotlin.UByte)/element), or -1 if the array does not contain element. ``` fun UByteArray.lastIndexOf(element: UByte): 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 UByteArray.lastOrNull(): UByte? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UByteArray.lastOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> UByteArray.map(transform: (UByte) -> 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.UByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> UByteArray.mapIndexed(     transform: (index: Int, UByte) -> 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.UByteArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%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.UByteArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, UByte) -> 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.UByteArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UByte,%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.UByteArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UByteArray.mapTo(     destination: C,     transform: (UByte) -> 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>> UByteArray.maxByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UByteArray.maxOf(selector: (UByte) -> Double): Double ``` ``` fun UByteArray.maxOf(selector: (UByte) -> Float): Float ``` ``` fun <R : Comparable<R>> UByteArray.maxOf(     selector: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UByteArray.maxOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` fun UByteArray.maxOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UByteArray.maxOfOrNull(     selector: (UByte) -> 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.UByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.UByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> 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.UByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.UByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> 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 UByteArray.maxOrNull(): UByte? ``` #### [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.UByteArray,%20kotlin.Comparator((kotlin.UByte)))/comparator). ``` fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UByteArray.maxWith(     comparator: Comparator<in UByte> ): UByte? ``` **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.UByteArray,%20kotlin.Comparator((kotlin.UByte)))/comparator) or `null` if there are no elements. ``` fun UByteArray.maxWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` 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>> UByteArray.minByOrNull(     selector: (UByte) -> R ): UByte? ``` ``` 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UByteArray.minOf(selector: (UByte) -> Double): Double ``` ``` fun UByteArray.minOf(selector: (UByte) -> Float): Float ``` ``` fun <R : Comparable<R>> UByteArray.minOf(     selector: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UByteArray.minOfOrNull(     selector: (UByte) -> Double ): Double? ``` ``` fun UByteArray.minOfOrNull(     selector: (UByte) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UByteArray.minOfOrNull(     selector: (UByte) -> 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.UByteArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.UByteArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (UByte) -> 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.UByteArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.UByteArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UByte,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UByte) -> 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 UByteArray.minOrNull(): UByte? ``` **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.UByteArray,%20kotlin.Comparator((kotlin.UByte)))/comparator). ``` fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UByteArray.minWith(     comparator: Comparator<in UByte> ): UByte? ``` **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.UByteArray,%20kotlin.Comparator((kotlin.UByte)))/comparator) or `null` if there are no elements. ``` fun UByteArray.minWithOrNull(     comparator: Comparator<in UByte> ): UByte? ``` ``` 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 UByteArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.none(predicate: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun UByteArray.onEach(action: (UByte) -> Unit): UByteArray ``` 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.UByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UByte,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun UByteArray.onEachIndexed(     action: (index: Int, UByte) -> Unit ): UByteArray ``` 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.UByteArray,%20kotlin.UByte)/element). ``` operator fun UByteArray.plus(element: UByte): UByteArray ``` 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.UByteArray,%20kotlin.collections.Collection((kotlin.UByte)))/elements) collection. ``` operator fun UByteArray.plus(     elements: Collection<UByte> ): UByteArray ``` 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.UByteArray,%20kotlin.UByteArray)/elements) array. ``` operator fun UByteArray.plus(     elements: UByteArray ): UByteArray ``` 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 UByteArray.random(): UByte ``` Returns a random element from this array using the specified source of randomness. ``` fun UByteArray.random(random: Random): UByte ``` **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 UByteArray.randomOrNull(): UByte? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun UByteArray.randomOrNull(random: Random): UByte? ``` **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.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UByteArray.reduce(     operation: (acc: UByte, UByte) -> UByte ): UByte ``` ``` 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.UByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UByteArray.reduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte ``` 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.UByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: UByte, UByte) -> UByte ): UByte? ``` 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.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UByteArray.reduceOrNull(     operation: (acc: UByte, UByte) -> UByte ): UByte? ``` ``` 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.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UByteArray.reduceRight(     operation: (UByte, acc: UByte) -> UByte ): UByte ``` **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.UByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UByteArray.reduceRightIndexed(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte ``` **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.UByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UByteArray.reduceRightIndexedOrNull(     operation: (index: Int, UByte, acc: UByte) -> UByte ): UByte? ``` **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.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UByteArray.reduceRightOrNull(     operation: (UByte, acc: UByte) -> UByte ): UByte? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun UByteArray.refTo(index: Int): CValuesRef<UByteVar> ``` **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 UByteArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun UByteArray.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 UByteArray.reversed(): List<UByte> ``` **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 UByteArray.reversedArray(): UByteArray ``` **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.UByteArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UByte,%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.UByteArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UByte,%20)))/initial) value. ``` fun <R> UByteArray.runningFold(     initial: R,     operation: (acc: R, UByte) -> 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.UByteArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UByte,%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.UByteArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UByte,%20)))/initial) value. ``` fun <R> UByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> 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.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun UByteArray.runningReduce(     operation: (acc: UByte, UByte) -> UByte ): List<UByte> ``` 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.UByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UByte,%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 UByteArray.runningReduceIndexed(     operation: (index: Int, acc: UByte, UByte) -> UByte ): List<UByte> ``` 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.UByteArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UByte,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.UByteArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UByte,%20)))/initial) value. ``` fun <R> UByteArray.scan(     initial: R,     operation: (acc: R, UByte) -> 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.UByteArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UByte,%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.UByteArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UByte,%20)))/initial) value. ``` fun <R> UByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, UByte) -> 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 UByteArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.UByteArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun UByteArray.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 UByteArray.single(): UByte ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun UByteArray.single(predicate: (UByte) -> Boolean): UByte ``` ``` 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 UByteArray.singleOrNull(): UByte? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun UByteArray.singleOrNull(     predicate: (UByte) -> Boolean ): UByte? ``` ``` 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.UByteArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UByteArray.slice(indices: IntRange): List<UByte> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.UByteArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun UByteArray.slice(indices: Iterable<Int>): List<UByte> ``` **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.UByteArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun UByteArray.sliceArray(     indices: Collection<Int> ): UByteArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.UByteArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UByteArray.sliceArray(indices: IntRange): UByteArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sort](../../kotlin.collections/sort) Sorts the array in-place. ``` fun UByteArray.sort() ``` Sorts a range in the array in-place. ``` fun UByteArray.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 UByteArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun UByteArray.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 UByteArray.sorted(): List<UByte> ``` **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 UByteArray.sortedArray(): UByteArray ``` **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 UByteArray.sortedArrayDescending(): UByteArray ``` **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 UByteArray.sortedDescending(): List<UByte> ``` **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 UByteArray.sum(): UInt ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.UInt)))/selector) function applied to each element in the array. ``` fun UByteArray.sumBy(selector: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UByteArray.sumByDouble(     selector: (UByte) -> 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.UByteArray,%20kotlin.Function1((kotlin.UByte,%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 UByteArray.sumOf(selector: (UByte) -> Double): Double ``` **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 UByteArray.sumOf(selector: (UByte) -> Long): Long ``` **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 UByteArray.sumOf(selector: (UByte) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun UByteArray.sumOf(     selector: (UByte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UByteArray.sumOf(     selector: (UByte) -> 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.UByteArray,%20kotlin.Int)/n) elements. ``` fun UByteArray.take(n: Int): List<UByte> ``` **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.UByteArray,%20kotlin.Int)/n) elements. ``` fun UByteArray.takeLast(n: Int): List<UByte> ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.takeLastWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` **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.UByteArray,%20kotlin.Function1((kotlin.UByte,%20kotlin.Boolean)))/predicate). ``` fun UByteArray.takeWhile(     predicate: (UByte) -> Boolean ): List<UByte> ``` ``` fun <T> Iterable<T>.takeWhile(     predicate: (T) -> Boolean ): List<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toByteArray](../../kotlin.collections/to-byte-array) Returns an array of type [ByteArray](../-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) #### [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 UByteArray.toCValues(): CValues<UByteVar> ``` **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) #### [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 UByteArray.toTypedArray(): Array<UByte> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../../kotlin.collections/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.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 UByteArray.withIndex(): Iterable<IndexedValue<UByte>> ``` **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.UByteArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> UByteArray.zip(     other: Array<out R> ): List<Pair<UByte, R>> ``` ``` infix fun UByteArray.zip(     other: UByteArray ): List<Pair<UByte, UByte>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UByteArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UByte,%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.UByteArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UByte,%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> UByteArray.zip(     other: Array<out R>,     transform: (a: UByte, 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.UByteArray,%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> UByteArray.zip(     other: Iterable<R> ): List<Pair<UByte, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UByteArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UByte,%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.UByteArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UByte,%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> UByteArray.zip(     other: Iterable<R>,     transform: (a: UByte, 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.UByteArray,%20kotlin.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UByteArray,%20kotlin.UByteArray,%20kotlin.Function2((kotlin.UByte,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> UByteArray.zip(     other: UByteArray,     transform: (a: UByte, b: UByte) -> 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) / [UByteArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun iterator(): Iterator<UByte> ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` UByteArray(size: Int) ``` Creates a new array of the specified size, with all elements initialized to zero. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun containsAll(elements: Collection<UByte>): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByteArray](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) / [UByteArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun set(index: Int, value: UByte) ``` Sets the element at the given [index](set#kotlin.UByteArray%24set(kotlin.Int,%20kotlin.UByte)/index) to the given [value](set#kotlin.UByteArray%24set(kotlin.Int,%20kotlin.UByte)/value). This method can be called using the index operator. If the [index](set#kotlin.UByteArray%24set(kotlin.Int,%20kotlin.UByte)/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) / [UByteArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun get(index: Int): UByte ``` Returns the array element at the given [index](get#kotlin.UByteArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.UByteArray%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 NotImplementedError NotImplementedError =================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NotImplementedError](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` class NotImplementedError : Error ``` An exception is thrown to indicate that a method body remains to be implemented. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) An exception is thrown to indicate that a method body remains to be implemented. ``` NotImplementedError(     message: String = "An operation is not implemented.") ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NotImplementedError](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` NotImplementedError(     message: String = "An operation is not implemented.") ``` An exception is thrown to indicate that a method body remains to be implemented. kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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 Short in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Converts this [Short](index#kotlin.Short) value to [Int](../-int/index#kotlin.Int). The resulting `Int` value represents the same numerical value as this `Short`. The least significant 16 bits of the resulting `Int` value are the same as the bits of this `Short` value, whereas the most significant 16 bits are filled with the sign bit of this value. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toByte(): Byte ``` Converts this [Short](index#kotlin.Short) 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 `Short`. The resulting `Byte` value is represented by the least significant 8 bits of this `Short` value. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Int ``` Returns this value. kotlin Short Short ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Short : Number, Comparable<Short> ``` ##### For Common, JVM, JS Represents a 16-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `short`. ##### For Native Represents a 16-bit signed integer. Functions --------- **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(): Short ``` **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): 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. ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Short): 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(): Short ``` **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): 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 ``` **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): 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 ``` **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.Short%24rangeTo(kotlin.Byte)/other) value. ``` operator fun rangeTo(other: Byte): IntRange ``` ``` operator fun rangeTo(other: Short): IntRange ``` ``` operator fun rangeTo(other: Int): IntRange ``` ``` 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.Short%24rangeUntil(kotlin.Byte)/other) value. ``` operator fun rangeUntil(other: Byte): IntRange ``` ``` operator fun rangeUntil(other: Short): IntRange ``` ``` operator fun rangeUntil(other: Int): IntRange ``` ``` 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): 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 ``` **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): 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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [Short](index#kotlin.Short) 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 [Short](index#kotlin.Short) 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 [Short](index#kotlin.Short) 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 [Short](index#kotlin.Short) 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 [Short](index#kotlin.Short) 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 [Short](index#kotlin.Short) 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) Returns this value. ``` 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(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Int ``` 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 Short can have. ``` const val MAX_VALUE: Short ``` **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 Short can have. ``` const val MIN_VALUE: Short ``` **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 Short 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 Short in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [and](../../kotlin.experimental/and) Performs a bitwise AND operation between the two values. ``` infix fun Short.and(other: Short): Short ``` **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.Short,%20kotlin.Short)/minimumValue). ``` fun Short.coerceAtLeast(minimumValue: Short): Short ``` ``` 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.Short,%20kotlin.Short)/maximumValue). ``` fun Short.coerceAtMost(maximumValue: Short): Short ``` ``` 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.Short,%20kotlin.Short,%20kotlin.Short)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Short,%20kotlin.Short,%20kotlin.Short)/maximumValue). ``` fun Short.coerceIn(     minimumValue: Short,     maximumValue: Short ): Short ``` ``` 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> Short.convert(): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countLeadingZeroBits](../count-leading-zero-bits) Counts the number of consecutive most significant bits that are zero in the binary representation of this [Short](index#kotlin.Short) number. ``` fun Short.countLeadingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countOneBits](../count-one-bits) Counts the number of set bits in the binary representation of this [Short](index#kotlin.Short) number. ``` fun Short.countOneBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countTrailingZeroBits](../count-trailing-zero-bits) Counts the number of consecutive least significant bits that are zero in the binary representation of this [Short](index#kotlin.Short) number. ``` fun Short.countTrailingZeroBits(): Int ``` **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.Short,%20kotlin.Byte)/to) value with the step -1. ``` infix fun Short.downTo(to: Byte): IntProgression ``` ``` infix fun Short.downTo(to: Int): IntProgression ``` ``` infix fun Short.downTo(to: Long): LongProgression ``` ``` infix fun Short.downTo(to: Short): IntProgression ``` **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 Short.floorDiv(other: Byte): Int ``` ``` fun Short.floorDiv(other: Short): Int ``` ``` fun Short.floorDiv(other: Int): Int ``` ``` fun Short.floorDiv(other: Long): Long ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [inv](../../kotlin.experimental/inv) Inverts the bits in this value. ``` fun Short.inv(): Short ``` **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 Short.mod(other: Byte): Byte ``` ``` fun Short.mod(other: Short): Short ``` ``` fun Short.mod(other: Int): Int ``` ``` fun Short.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.1), JS (1.1), Native (1.1) #### [or](../../kotlin.experimental/or) Performs a bitwise OR operation between the two values. ``` infix fun Short.or(other: Short): Short ``` **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 [Short](index#kotlin.Short) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.Short,%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 Short.rotateLeft(bitCount: Int): Short ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [Short](index#kotlin.Short) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.Short,%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 Short.rotateRight(bitCount: Int): Short ``` **Platform and version requirements:** Native (1.3) #### [signExtend](../../kotlinx.cinterop/sign-extend) ``` fun <R : Number> Number.signExtend(): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeHighestOneBit](../take-highest-one-bit) Returns a number having a single bit set in the position of the most significant set bit of this [Short](index#kotlin.Short) number, or zero, if this number is zero. ``` fun Short.takeHighestOneBit(): Short ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeLowestOneBit](../take-lowest-one-bit) Returns a number having a single bit set in the position of the least significant set bit of this [Short](index#kotlin.Short) number, or zero, if this number is zero. ``` fun Short.takeLowestOneBit(): Short ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](../to-u-byte) Converts this [Short](index#kotlin.Short) value to [UByte](../-u-byte/index). ``` fun Short.toUByte(): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Short](index#kotlin.Short) value to [UInt](../-u-int/index). ``` fun Short.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Short](index#kotlin.Short) value to [ULong](../-u-long/index). ``` fun Short.toULong(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](../to-u-short) Converts this [Short](index#kotlin.Short) value to [UShort](../-u-short/index). ``` fun Short.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.Short,%20kotlin.Byte)/to) value. ``` infix fun Short.until(to: Byte): IntRange ``` ``` infix fun Short.until(to: Int): IntRange ``` ``` infix fun Short.until(to: Long): LongRange ``` ``` infix fun Short.until(to: Short): IntRange ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [xor](../../kotlin.experimental/xor) Performs a bitwise XOR operation between the two values. ``` infix fun Short.xor(other: Short): Short ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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 Short in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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: Short ``` A constant holding the minimum value an instance of Short can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Converts this [Short](index#kotlin.Short) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `Short`. The least significant 16 bits of the resulting `Long` value are the same as the bits of this `Short` value, whereas the most significant 48 bits are filled with the sign bit of this value. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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: Short ``` A constant holding the maximum value an instance of Short can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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) / [Short](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.Short%24rangeTo(kotlin.Byte)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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) / [Short](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.Short%24rangeUntil(kotlin.Byte)/other) value. If the [other](range-until#kotlin.Short%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) / [Short](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) / [Short](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Converts this [Short](index#kotlin.Short) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `Short`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Short ``` 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) / [Short](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) / [Short](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Short ``` 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) / [Short](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) / [Short](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) / [Short](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: Short): Boolean ``` kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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) / [Short](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Converts this [Short](index#kotlin.Short) value to [Float](../-float/index#kotlin.Float). The resulting `Float` value represents the same numerical value as this `Short`. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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) / [Short](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toShort(): Short ``` Returns this value. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Short](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) / [Short](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 [Short](index#kotlin.Short) value to [Char](../-char/index#kotlin.Char). The resulting `Char` code is equal to this value reinterpreted as an unsigned number, i.e. it has the same binary representation as this `Short`. kotlin isSuccess isSuccess ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / [isSuccess](is-success) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val isSuccess: Boolean ``` Returns `true` if this instance represents a successful outcome. In this case [isFailure](is-failure) returns `false`. kotlin Result Result ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` inline class Result<out T> : Serializable ``` A discriminated union that encapsulates a successful outcome with a value of type [T](index#T) or a failure with an arbitrary [Throwable](../-throwable/index#kotlin.Throwable) exception. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isFailure](is-failure) Returns `true` if this instance represents a failed outcome. In this case [isSuccess](is-success) returns `false`. ``` val isFailure: Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isSuccess](is-success) Returns `true` if this instance represents a successful outcome. In this case [isFailure](is-failure) returns `false`. ``` val isSuccess: Boolean ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [exceptionOrNull](exception-or-null) Returns the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if this instance represents [failure](is-failure) or `null` if it is [success](is-success). ``` fun exceptionOrNull(): Throwable? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getOrNull](get-or-null) Returns the encapsulated value if this instance represents [success](is-success) or `null` if it is [failure](is-failure). ``` fun getOrNull(): T? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns a string `Success(v)` if this instance represents [success](is-success) where `v` is a string representation of the value or a string `Failure(x)` if it is [failure](is-failure) where `x` is a string representation of the exception. ``` fun toString(): String ``` Companion Object Functions -------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <failure> Returns an instance that encapsulates the given [Throwable](failure#kotlin.Result.Companion%24failure(kotlin.Throwable)/exception) as failure. ``` fun <T> failure(exception: Throwable): Result<T> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <success> Returns an instance that encapsulates the given [value](success#kotlin.Result.Companion%24success(kotlin.Result.Companion.success.T)/value) as successful value. ``` fun <T> success(value: T): Result<T> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [fold](../fold) Returns the result of [onSuccess](../fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onSuccess) for the encapsulated value if this instance represents [success](is-success) or the result of [onFailure](../fold#kotlin%24fold(kotlin.Result((kotlin.fold.T)),%20kotlin.Function1((kotlin.fold.T,%20kotlin.fold.R)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.fold.R)))/onFailure) function for the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if it is [failure](is-failure). ``` fun <R, T> Result<T>.fold(     onSuccess: (value: T) -> R,     onFailure: (exception: Throwable) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrDefault](../get-or-default) Returns the encapsulated value if this instance represents [success](is-success) or the [defaultValue](../get-or-default#kotlin%24getOrDefault(kotlin.Result((kotlin.getOrDefault.T)),%20kotlin.getOrDefault.R)/defaultValue) if it is [failure](is-failure). ``` fun <R, T : R> Result<T>.getOrDefault(defaultValue: R): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrElse](../get-or-else) Returns the encapsulated value if this instance represents [success](is-success) or the result of [onFailure](../get-or-else#kotlin%24getOrElse(kotlin.Result((kotlin.getOrElse.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.getOrElse.R)))/onFailure) function for the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if it is [failure](is-failure). ``` fun <R, T : R> Result<T>.getOrElse(     onFailure: (exception: Throwable) -> R ): R ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [getOrThrow](../get-or-throw) Returns the encapsulated value if this instance represents [success](is-success) or throws the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if it is [failure](is-failure). ``` fun <T> Result<T>.getOrThrow(): T ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [map](../map) Returns the encapsulated result of the given [transform](../map#kotlin%24map(kotlin.Result((kotlin.map.T)),%20kotlin.Function1((kotlin.map.T,%20kotlin.map.R)))/transform) function applied to the encapsulated value if this instance represents [success](is-success) or the original encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if it is [failure](is-failure). ``` fun <R, T> Result<T>.map(     transform: (value: T) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [mapCatching](../map-catching) Returns the encapsulated result of the given [transform](../map-catching#kotlin%24mapCatching(kotlin.Result((kotlin.mapCatching.T)),%20kotlin.Function1((kotlin.mapCatching.T,%20kotlin.mapCatching.R)))/transform) function applied to the encapsulated value if this instance represents [success](is-success) or the original encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if it is [failure](is-failure). ``` fun <R, T> Result<T>.mapCatching(     transform: (value: T) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [onFailure](../on-failure) Performs the given [action](../on-failure#kotlin%24onFailure(kotlin.Result((kotlin.onFailure.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.Unit)))/action) on the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if this instance represents [failure](is-failure). Returns the original `Result` unchanged. ``` fun <T> Result<T>.onFailure(     action: (exception: Throwable) -> Unit ): Result<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [onSuccess](../on-success) Performs the given [action](../on-success#kotlin%24onSuccess(kotlin.Result((kotlin.onSuccess.T)),%20kotlin.Function1((kotlin.onSuccess.T,%20kotlin.Unit)))/action) on the encapsulated value if this instance represents [success](is-success). Returns the original `Result` unchanged. ``` fun <T> Result<T>.onSuccess(     action: (value: T) -> Unit ): Result<T> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [recover](../recover) Returns the encapsulated result of the given [transform](../recover#kotlin%24recover(kotlin.Result((kotlin.recover.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recover.R)))/transform) function applied to the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if this instance represents [failure](is-failure) or the original encapsulated value if it is [success](is-success). ``` fun <R, T : R> Result<T>.recover(     transform: (exception: Throwable) -> R ): Result<R> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [recoverCatching](../recover-catching) Returns the encapsulated result of the given [transform](../recover-catching#kotlin%24recoverCatching(kotlin.Result((kotlin.recoverCatching.T)),%20kotlin.Function1((kotlin.Throwable,%20kotlin.recoverCatching.R)))/transform) function applied to the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if this instance represents [failure](is-failure) or the original encapsulated value if it is [success](is-success). ``` fun <R, T : R> Result<T>.recoverCatching(     transform: (exception: Throwable) -> R ): Result<R> ```
programming_docs
kotlin failure failure ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / <failure> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("failure") fun <T> failure(     exception: Throwable ): Result<T> ``` Returns an instance that encapsulates the given [Throwable](failure#kotlin.Result.Companion%24failure(kotlin.Throwable)/exception) as failure. kotlin exceptionOrNull exceptionOrNull =============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / [exceptionOrNull](exception-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun exceptionOrNull(): Throwable? ``` Returns the encapsulated [Throwable](../-throwable/index#kotlin.Throwable) exception if this instance represents [failure](is-failure) or `null` if it is [success](is-success). This function is a shorthand for `fold(onSuccess = { null }, onFailure = { it })` (see [fold](../fold)). kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns a string `Success(v)` if this instance represents [success](is-success) where `v` is a string representation of the value or a string `Failure(x)` if it is [failure](is-failure) where `x` is a string representation of the exception. kotlin success success ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / <success> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @JvmName("success") fun <T> success(value: T): Result<T> ``` Returns an instance that encapsulates the given [value](success#kotlin.Result.Companion%24success(kotlin.Result.Companion.success.T)/value) as successful value. kotlin getOrNull getOrNull ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / [getOrNull](get-or-null) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun getOrNull(): T? ``` Returns the encapsulated value if this instance represents [success](is-success) or `null` if it is [failure](is-failure). This function is a shorthand for `getOrElse { null }` (see [getOrElse](../get-or-else)) or `fold(onSuccess = { it }, onFailure = { null })` (see [fold](../fold)). kotlin isFailure isFailure ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Result](index) / [isFailure](is-failure) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val isFailure: Boolean ``` Returns `true` if this instance represents a failed outcome. In this case [isSuccess](is-success) returns `false`. kotlin Unit Unit ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Unit](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` object Unit ``` ##### For Common, JVM, JS The type with only one value: the `Unit` object. This type corresponds to the `void` type in Java. ##### For Native The type with only one value: the `Unit` object. Functions --------- **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 toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Unit](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` fun toString(): String ``` Returns a string representation of the object. kotlin UnsafeVariance UnsafeVariance ============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UnsafeVariance](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([AnnotationTarget.TYPE]) annotation class UnsafeVariance ``` Suppresses errors about variance conflict Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Suppresses errors about variance conflict ``` <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) / [UnsafeVariance](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` Suppresses errors about variance conflict kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin CharArray CharArray ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class CharArray ``` ##### For Common, JVM, JS An array of chars. When targeting the JVM, instances of this class are represented as `char[]`. ##### For Native An array of chars. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Char) ``` Creates a new array of the specified [size](size#kotlin.CharArray%24size), with all elements initialized to null char (`\u0000'). ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.CharArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Char ``` **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(): CharIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/index) to the given [value](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Char) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val CharArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val CharArray.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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.all(predicate: (Char) -> 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 CharArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.any(predicate: (Char) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun CharArray.asIterable(): Iterable<Char> ``` **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 array returning its elements when being iterated. ``` fun CharArray.asSequence(): Sequence<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> CharArray.associate(     transform: (Char) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> CharArray.associateBy(     keySelector: (Char) -> K ): Map<K, Char> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> CharArray.associateBy(     keySelector: (Char) -> K,     valueTransform: (Char) -> 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.CharArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Char>> CharArray.associateByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.CharArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.CharArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> CharArray.associateByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> 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.CharArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> CharArray.associateTo(     destination: M,     transform: (Char) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> CharArray.associateWith(     valueSelector: (Char) -> V ): Map<Char, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.CharArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Char, in V>> CharArray.associateWithTo(     destination: M,     valueSelector: (Char) -> V ): M ``` **Platform and version requirements:** JVM (1.0) #### [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.CharArray,%20kotlin.Char,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun CharArray.binarySearch(     element: Char,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun CharArray.component1(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun CharArray.component2(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun CharArray.component3(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun CharArray.component4(): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun CharArray.component5(): Char ``` **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.CharArray,%20kotlin.Char)/element) is found in the array. ``` operator fun CharArray.contains(element: Char): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun CharArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.count(predicate: (Char) -> 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 array. ``` fun CharArray.distinct(): List<Char> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> CharArray.distinctBy(     selector: (Char) -> K ): List<Char> ``` **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.CharArray,%20kotlin.Int)/n) elements. ``` fun CharArray.drop(n: Int): List<Char> ``` **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.CharArray,%20kotlin.Int)/n) elements. ``` fun CharArray.dropLast(n: Int): List<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.dropLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.dropWhile(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) is out of bounds of this array. ``` fun CharArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.CharArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.CharArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun CharArray.elementAtOrNull(index: Int): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.filter(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.filterIndexed(     predicate: (index: Int, Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.CharArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Char>> CharArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Char) -> Boolean ): 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.filterNot(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.CharArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Char>> CharArray.filterNotTo(     destination: C,     predicate: (Char) -> 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.CharArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.CharArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Char>> CharArray.filterTo(     destination: C,     predicate: (Char) -> 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun CharArray.find(predicate: (Char) -> Boolean): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun CharArray.findLast(predicate: (Char) -> Boolean): Char? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun CharArray.first(): Char ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.first(predicate: (Char) -> Boolean): Char ``` **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 CharArray.firstOrNull(): Char? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun CharArray.firstOrNull(     predicate: (Char) -> Boolean ): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> CharArray.flatMap(     transform: (Char) -> Iterable<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.CharArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> CharArray.flatMapIndexed(     transform: (index: Int, Char) -> Iterable<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.CharArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%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.CharArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> CharArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Char) -> Iterable<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.CharArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> CharArray.flatMapTo(     destination: C,     transform: (Char) -> Iterable<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.CharArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Char,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.CharArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Char,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> CharArray.fold(     initial: R,     operation: (acc: R, Char) -> 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.CharArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Char,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.CharArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Char,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> CharArray.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](../../kotlin.collections/fold-right) Accumulates value starting with [initial](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.CharArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Char,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.CharArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Char,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> CharArray.foldRight(     initial: R,     operation: (Char, 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.CharArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.CharArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%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> CharArray.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](../../kotlin.collections/for-each) Performs the given [action](../../kotlin.collections/for-each#kotlin.collections%24forEach(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each element. ``` fun CharArray.forEach(action: (Char) -> 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.CharArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun CharArray.forEachIndexed(     action: (index: Int, Char) -> 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.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.CharArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) is out of bounds of this array. ``` fun CharArray.getOrElse(     index: Int,     defaultValue: (Int) -> Char ): Char ``` **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.CharArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.CharArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun CharArray.getOrNull(index: Int): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%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> CharArray.groupBy(     keySelector: (Char) -> K ): Map<K, List<Char>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Char,%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> CharArray.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](../../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.CharArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.CharArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Char>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.CharArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.CharArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Char,%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>>> CharArray.groupByTo(     destination: M,     keySelector: (Char) -> K,     valueTransform: (Char) -> V ): M ``` **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.CharArray,%20kotlin.Char)/element), or -1 if the array does not contain element. ``` fun CharArray.indexOf(element: Char): 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun CharArray.indexOfFirst(predicate: (Char) -> 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun CharArray.indexOfLast(predicate: (Char) -> 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 array and the specified collection. ``` infix fun CharArray.intersect(     other: Iterable<Char> ): Set<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun CharArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun CharArray.isNotEmpty(): 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.CharArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.CharArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.CharArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> CharArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> 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.CharArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.CharArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.CharArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Char,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun CharArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Char) -> 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 CharArray.last(): Char ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.last(predicate: (Char) -> Boolean): Char ``` **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.CharArray,%20kotlin.Char)/element), or -1 if the array does not contain element. ``` fun CharArray.lastIndexOf(element: Char): 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 CharArray.lastOrNull(): Char? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun CharArray.lastOrNull(predicate: (Char) -> Boolean): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> CharArray.map(transform: (Char) -> 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.CharArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> CharArray.mapIndexed(     transform: (index: Int, Char) -> R ): List<R> ``` **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.CharArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%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.CharArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> CharArray.mapIndexedTo(     destination: C,     transform: (index: Int, Char) -> 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.CharArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Char,%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.CharArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> CharArray.mapTo(     destination: C,     transform: (Char) -> 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>> CharArray.maxByOrNull(     selector: (Char) -> R ): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Char) -> 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Char) -> 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.CharArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.CharArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> CharArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Char) -> 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.CharArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.CharArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> CharArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> 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 CharArray.maxOrNull(): Char? ``` #### [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.CharArray,%20kotlin.Comparator((kotlin.Char)))/comparator). ``` fun CharArray.maxWith(comparator: Comparator<in Char>): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharArray.maxWith(comparator: Comparator<in Char>): Char? ``` **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.CharArray,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no elements. ``` fun CharArray.maxWithOrNull(     comparator: Comparator<in Char> ): Char? ``` **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>> CharArray.minByOrNull(     selector: (Char) -> R ): Char? ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Char) -> 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Char) -> 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.CharArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.CharArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> CharArray.minOfWith(     comparator: Comparator<in R>,     selector: (Char) -> 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.CharArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.CharArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Char,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> CharArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Char) -> 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 CharArray.minOrNull(): Char? ``` #### [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.CharArray,%20kotlin.Comparator((kotlin.Char)))/comparator). ``` fun CharArray.minWith(comparator: Comparator<in Char>): Char ``` **Platform and version requirements:** JVM (1.0) ``` fun CharArray.minWith(comparator: Comparator<in Char>): Char? ``` **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.CharArray,%20kotlin.Comparator((kotlin.Char)))/comparator) or `null` if there are no elements. ``` fun CharArray.minWithOrNull(     comparator: Comparator<in Char> ): Char? ``` **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 CharArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.none(predicate: (Char) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun CharArray.onEach(action: (Char) -> Unit): CharArray ``` **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.CharArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Char,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun CharArray.onEachIndexed(     action: (index: Int, Char) -> Unit ): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun CharArray.partition(     predicate: (Char) -> Boolean ): Pair<List<Char>, List<Char>> ``` **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 CharArray.random(): Char ``` Returns a random element from this array using the specified source of randomness. ``` fun CharArray.random(random: Random): Char ``` **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 CharArray.randomOrNull(): Char? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun CharArray.randomOrNull(random: Random): Char? ``` **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.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun CharArray.reduce(     operation: (acc: Char, Char) -> Char ): Char ``` **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.CharArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun CharArray.reduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): Char ``` **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.CharArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun CharArray.reduceIndexedOrNull(     operation: (index: Int, acc: Char, Char) -> Char ): Char? ``` **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.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun CharArray.reduceOrNull(     operation: (acc: Char, Char) -> Char ): Char? ``` **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.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun CharArray.reduceRight(     operation: (Char, acc: Char) -> Char ): Char ``` **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.CharArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun CharArray.reduceRightIndexed(     operation: (index: Int, Char, acc: Char) -> Char ): Char ``` **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.CharArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun CharArray.reduceRightIndexedOrNull(     operation: (index: Int, Char, acc: Char) -> Char ): Char? ``` **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.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun CharArray.reduceRightOrNull(     operation: (Char, acc: Char) -> Char ): Char? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun CharArray.refTo(index: Int): CValuesRef<COpaque> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun CharArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun CharArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 CharArray.reversed(): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun CharArray.reversedArray(): CharArray ``` **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.CharArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Char,%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.CharArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharArray.runningFold(     initial: R,     operation: (acc: R, Char) -> 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.CharArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Char,%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.CharArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharArray.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](../../kotlin.collections/running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.collections/running-reduce#kotlin.collections%24runningReduce(kotlin.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun CharArray.runningReduce(     operation: (acc: Char, Char) -> Char ): List<Char> ``` **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.CharArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Char,%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 CharArray.runningReduceIndexed(     operation: (index: Int, acc: Char, Char) -> Char ): List<Char> ``` **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.CharArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Char,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.CharArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharArray.scan(     initial: R,     operation: (acc: R, Char) -> 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.CharArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Char,%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.CharArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Char,%20)))/initial) value. ``` fun <R> CharArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Char) -> 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 CharArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.CharArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun CharArray.shuffle(random: Random) ``` **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 CharArray.single(): Char ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun CharArray.single(predicate: (Char) -> Boolean): Char ``` **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 CharArray.singleOrNull(): Char? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun CharArray.singleOrNull(     predicate: (Char) -> Boolean ): Char? ``` **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.CharArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun CharArray.slice(indices: IntRange): List<Char> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.CharArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun CharArray.slice(indices: Iterable<Int>): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.CharArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun CharArray.sliceArray(indices: Collection<Int>): CharArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.CharArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun CharArray.sliceArray(indices: IntRange): CharArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.Int)))/comparison) function. ``` fun CharArray.sort(comparison: (a: Char, b: Char) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun CharArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun CharArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun CharArray.sorted(): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun CharArray.sortedArray(): CharArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun CharArray.sortedArrayDescending(): CharArray ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> CharArray.sortedBy(     selector: (Char) -> R? ): List<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> CharArray.sortedByDescending(     selector: (Char) -> R? ): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun CharArray.sortedDescending(): List<Char> ``` **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.CharArray,%20kotlin.Comparator((kotlin.Char)))/comparator). ``` fun CharArray.sortedWith(     comparator: Comparator<in Char> ): List<Char> ``` **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 array and not contained by the specified collection. ``` infix fun CharArray.subtract(     other: Iterable<Char> ): Set<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun CharArray.sumBy(selector: (Char) -> 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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun CharArray.sumByDouble(selector: (Char) -> Double): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.CharArray,%20kotlin.Function1((kotlin.Char,%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 CharArray.sumOf(selector: (Char) -> Double): Double ``` **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 CharArray.sumOf(selector: (Char) -> Long): Long ``` **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 CharArray.sumOf(selector: (Char) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun CharArray.sumOf(     selector: (Char) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun CharArray.sumOf(     selector: (Char) -> BigInteger ): BigInteger ``` **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.CharArray,%20kotlin.Int)/n) elements. ``` fun CharArray.take(n: Int): List<Char> ``` **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.CharArray,%20kotlin.Int)/n) elements. ``` fun CharArray.takeLast(n: Int): List<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.takeLastWhile(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharArray.takeWhile(     predicate: (Char) -> Boolean ): List<Char> ``` **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.CharArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Char>> CharArray.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 CharArray.toHashSet(): HashSet<Char> ``` **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 CharArray.toList(): List<Char> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun CharArray.toMutableList(): MutableList<Char> ``` **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 array. ``` fun CharArray.toMutableSet(): MutableSet<Char> ``` **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 CharArray.toSet(): Set<Char> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun CharArray.toSortedSet(): SortedSet<Char> ``` **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 CharArray.union(other: Iterable<Char>): Set<Char> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun CharArray.withIndex(): Iterable<IndexedValue<Char>> ``` **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.CharArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Char, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.CharArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Char,%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.CharArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Char,%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> CharArray.zip(     other: Array<out R>,     transform: (a: Char, 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.CharArray,%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> CharArray.zip(     other: Iterable<R> ): List<Pair<Char, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.CharArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Char,%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.CharArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Char,%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> CharArray.zip(     other: Iterable<R>,     transform: (a: Char, 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.CharArray,%20kotlin.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.CharArray,%20kotlin.CharArray,%20kotlin.Function2((kotlin.Char,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> CharArray.zip(     other: CharArray,     transform: (a: Char, b: Char) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): CharIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Char) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.CharArray%24size), with all elements initialized to null char (`\u0000'). **Constructor** Creates a new array of the specified [size](size#kotlin.CharArray%24size), with all elements initialized to null char (`\u0000'). kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Char) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/index) to the given [value](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/value). This method can be called using the index operator. If the [index](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/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. ##### For Native Sets the element at the given [index](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/index) to the given [value](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/value). This method can be called using the index operator. If the [index](set#kotlin.CharArray%24set(kotlin.Int,%20kotlin.Char)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [CharArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Char ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.CharArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.CharArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.CharArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.CharArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin ConcurrentModificationException ConcurrentModificationException =============================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ConcurrentModificationException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class ConcurrentModificationException : RuntimeException ``` **Platform and version requirements:** JVM (1.3) ``` typealias ConcurrentModificationException = ConcurrentModificationException ``` 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) / [ConcurrentModificationException](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 AssertionError AssertionError ============== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [AssertionError](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 ``` Constructors ------------ #### [<init>](-init-) **Platform and version requirements:** JS (1.1) ``` AssertionError(message: String?) ``` **Platform and version requirements:** Native (1.3) ``` AssertionError(cause: Throwable?) ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>() ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>(message: Any?) ``` **Platform and version requirements:** JS (1.1), Native (1.3) ``` <init>(message: String?, 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) / [AssertionError](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: Any?) ``` **Platform and version requirements:** JS (1.1) ``` AssertionError(message: String?) ``` **Platform and version requirements:** Native (1.3) ``` AssertionError(cause: Throwable?) ``` **Platform and version requirements:** JS (1.1), Native (1.1) ``` <init>(message: String?, cause: Throwable?) ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin LongArray LongArray ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class LongArray ``` ##### For Common, JVM, JS An array of longs. When targeting the JVM, instances of this class are represented as `long[]`. ##### For Native An array of longs. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Long) ``` Creates a new array of the specified [size](size#kotlin.LongArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.LongArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Long ``` **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(): LongIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/index) to the given [value](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Long) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val LongArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val LongArray.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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.all(predicate: (Long) -> 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 LongArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.any(predicate: (Long) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun LongArray.asIterable(): Iterable<Long> ``` **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 array returning its elements when being iterated. ``` fun LongArray.asSequence(): Sequence<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> LongArray.associate(     transform: (Long) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> LongArray.associateBy(     keySelector: (Long) -> K ): Map<K, Long> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> LongArray.associateBy(     keySelector: (Long) -> K,     valueTransform: (Long) -> 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.LongArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Long>> LongArray.associateByTo(     destination: M,     keySelector: (Long) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.LongArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.LongArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> LongArray.associateByTo(     destination: M,     keySelector: (Long) -> K,     valueTransform: (Long) -> 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.LongArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> LongArray.associateTo(     destination: M,     transform: (Long) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> LongArray.associateWith(     valueSelector: (Long) -> V ): Map<Long, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.LongArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Long, in V>> LongArray.associateWithTo(     destination: M,     valueSelector: (Long) -> V ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asULongArray](../../kotlin.collections/as-u-long-array) Returns an array of type [ULongArray](../-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.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun LongArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.LongArray,%20kotlin.Long,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun LongArray.binarySearch(     element: Long,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun LongArray.component1(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun LongArray.component2(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun LongArray.component3(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun LongArray.component4(): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun LongArray.component5(): Long ``` **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.LongArray,%20kotlin.Long)/element) is found in the array. ``` operator fun LongArray.contains(element: Long): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun LongArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.count(predicate: (Long) -> 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 array. ``` fun LongArray.distinct(): List<Long> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> LongArray.distinctBy(     selector: (Long) -> K ): List<Long> ``` **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.LongArray,%20kotlin.Int)/n) elements. ``` fun LongArray.drop(n: Int): List<Long> ``` **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.LongArray,%20kotlin.Int)/n) elements. ``` fun LongArray.dropLast(n: Int): List<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.dropLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.dropWhile(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/index) is out of bounds of this array. ``` fun LongArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.LongArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.LongArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun LongArray.elementAtOrNull(index: Int): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.filter(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.filterIndexed(     predicate: (index: Int, Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.LongArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Long>> LongArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Long) -> Boolean ): 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.filterNot(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.LongArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Long>> LongArray.filterNotTo(     destination: C,     predicate: (Long) -> 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.LongArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.LongArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Long>> LongArray.filterTo(     destination: C,     predicate: (Long) -> 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun LongArray.find(predicate: (Long) -> Boolean): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun LongArray.findLast(predicate: (Long) -> Boolean): Long? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun LongArray.first(): Long ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.first(predicate: (Long) -> Boolean): Long ``` **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 LongArray.firstOrNull(): Long? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun LongArray.firstOrNull(     predicate: (Long) -> Boolean ): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> LongArray.flatMap(     transform: (Long) -> Iterable<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.LongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> LongArray.flatMapIndexed(     transform: (index: Int, Long) -> Iterable<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.LongArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%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.LongArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> LongArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Long) -> Iterable<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.LongArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> LongArray.flatMapTo(     destination: C,     transform: (Long) -> Iterable<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.LongArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Long,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.LongArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Long,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> LongArray.fold(     initial: R,     operation: (acc: R, Long) -> 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.LongArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Long,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.LongArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Long,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> LongArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> 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.LongArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Long,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.LongArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Long,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> LongArray.foldRight(     initial: R,     operation: (Long, 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.LongArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.LongArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%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> LongArray.foldRightIndexed(     initial: R,     operation: (index: Int, Long, 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Unit)))/action) on each element. ``` fun LongArray.forEach(action: (Long) -> 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.LongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun LongArray.forEachIndexed(     action: (index: Int, Long) -> 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.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.LongArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Long)))/index) is out of bounds of this array. ``` fun LongArray.getOrElse(     index: Int,     defaultValue: (Int) -> Long ): Long ``` **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.LongArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.LongArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun LongArray.getOrNull(index: Int): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%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> LongArray.groupBy(     keySelector: (Long) -> K ): Map<K, List<Long>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Long,%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> LongArray.groupBy(     keySelector: (Long) -> K,     valueTransform: (Long) -> 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.LongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.LongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Long>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.LongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.LongArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Long,%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>>> LongArray.groupByTo(     destination: M,     keySelector: (Long) -> K,     valueTransform: (Long) -> V ): M ``` **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.LongArray,%20kotlin.Long)/element), or -1 if the array does not contain element. ``` fun LongArray.indexOf(element: Long): 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun LongArray.indexOfFirst(predicate: (Long) -> 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun LongArray.indexOfLast(predicate: (Long) -> 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 array and the specified collection. ``` infix fun LongArray.intersect(     other: Iterable<Long> ): Set<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun LongArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun LongArray.isNotEmpty(): 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.LongArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.LongArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.LongArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> LongArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> 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.LongArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.LongArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.LongArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Long,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun LongArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Long) -> 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 LongArray.last(): Long ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.last(predicate: (Long) -> Boolean): Long ``` **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.LongArray,%20kotlin.Long)/element), or -1 if the array does not contain element. ``` fun LongArray.lastIndexOf(element: Long): 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 LongArray.lastOrNull(): Long? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun LongArray.lastOrNull(predicate: (Long) -> Boolean): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> LongArray.map(transform: (Long) -> 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.LongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> LongArray.mapIndexed(     transform: (index: Int, Long) -> R ): List<R> ``` **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.LongArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%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.LongArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> LongArray.mapIndexedTo(     destination: C,     transform: (index: Int, Long) -> 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.LongArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Long,%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.LongArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> LongArray.mapTo(     destination: C,     transform: (Long) -> 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>> LongArray.maxByOrNull(     selector: (Long) -> R ): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Long) -> 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Long) -> 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.LongArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.LongArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> LongArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Long) -> 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.LongArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.LongArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> LongArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> 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 LongArray.maxOrNull(): Long? ``` #### [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.LongArray,%20kotlin.Comparator((kotlin.Long)))/comparator). ``` fun LongArray.maxWith(comparator: Comparator<in Long>): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun LongArray.maxWith(comparator: Comparator<in Long>): Long? ``` **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.LongArray,%20kotlin.Comparator((kotlin.Long)))/comparator) or `null` if there are no elements. ``` fun LongArray.maxWithOrNull(     comparator: Comparator<in Long> ): Long? ``` **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>> LongArray.minByOrNull(     selector: (Long) -> R ): Long? ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Long) -> 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Long) -> 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.LongArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.LongArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> LongArray.minOfWith(     comparator: Comparator<in R>,     selector: (Long) -> 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.LongArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.LongArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Long,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> LongArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Long) -> 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 LongArray.minOrNull(): Long? ``` #### [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.LongArray,%20kotlin.Comparator((kotlin.Long)))/comparator). ``` fun LongArray.minWith(comparator: Comparator<in Long>): Long ``` **Platform and version requirements:** JVM (1.0) ``` fun LongArray.minWith(comparator: Comparator<in Long>): Long? ``` **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.LongArray,%20kotlin.Comparator((kotlin.Long)))/comparator) or `null` if there are no elements. ``` fun LongArray.minWithOrNull(     comparator: Comparator<in Long> ): Long? ``` **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 LongArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.none(predicate: (Long) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun LongArray.onEach(action: (Long) -> Unit): LongArray ``` **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.LongArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Long,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun LongArray.onEachIndexed(     action: (index: Int, Long) -> Unit ): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun LongArray.partition(     predicate: (Long) -> Boolean ): Pair<List<Long>, List<Long>> ``` **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 LongArray.random(): Long ``` Returns a random element from this array using the specified source of randomness. ``` fun LongArray.random(random: Random): Long ``` **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 LongArray.randomOrNull(): Long? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun LongArray.randomOrNull(random: Random): Long? ``` **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.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun LongArray.reduce(     operation: (acc: Long, Long) -> Long ): Long ``` **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.LongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun LongArray.reduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): Long ``` **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.LongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun LongArray.reduceIndexedOrNull(     operation: (index: Int, acc: Long, Long) -> Long ): Long? ``` **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.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun LongArray.reduceOrNull(     operation: (acc: Long, Long) -> Long ): Long? ``` **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.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun LongArray.reduceRight(     operation: (Long, acc: Long) -> Long ): Long ``` **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.LongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun LongArray.reduceRightIndexed(     operation: (index: Int, Long, acc: Long) -> Long ): Long ``` **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.LongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun LongArray.reduceRightIndexedOrNull(     operation: (index: Int, Long, acc: Long) -> Long ): Long? ``` **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.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun LongArray.reduceRightOrNull(     operation: (Long, acc: Long) -> Long ): Long? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun LongArray.refTo(index: Int): CValuesRef<LongVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun LongArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun LongArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 LongArray.reversed(): List<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun LongArray.reversedArray(): LongArray ``` **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.LongArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Long,%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.LongArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Long,%20)))/initial) value. ``` fun <R> LongArray.runningFold(     initial: R,     operation: (acc: R, Long) -> 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.LongArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Long,%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.LongArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Long,%20)))/initial) value. ``` fun <R> LongArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> 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.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun LongArray.runningReduce(     operation: (acc: Long, Long) -> Long ): List<Long> ``` **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.LongArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Long,%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 LongArray.runningReduceIndexed(     operation: (index: Int, acc: Long, Long) -> Long ): List<Long> ``` **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.LongArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Long,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.LongArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Long,%20)))/initial) value. ``` fun <R> LongArray.scan(     initial: R,     operation: (acc: R, Long) -> 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.LongArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Long,%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.LongArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Long,%20)))/initial) value. ``` fun <R> LongArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Long) -> 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 LongArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.LongArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun LongArray.shuffle(random: Random) ``` **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 LongArray.single(): Long ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun LongArray.single(predicate: (Long) -> Boolean): Long ``` **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 LongArray.singleOrNull(): Long? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun LongArray.singleOrNull(     predicate: (Long) -> Boolean ): Long? ``` **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.LongArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun LongArray.slice(indices: IntRange): List<Long> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.LongArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun LongArray.slice(indices: Iterable<Int>): List<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.LongArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun LongArray.sliceArray(indices: Collection<Int>): LongArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.LongArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun LongArray.sliceArray(indices: IntRange): LongArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20kotlin.Int)))/comparison) function. ``` fun LongArray.sort(comparison: (a: Long, b: Long) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun LongArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun LongArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun LongArray.sorted(): List<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun LongArray.sortedArray(): LongArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun LongArray.sortedArrayDescending(): LongArray ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> LongArray.sortedBy(     selector: (Long) -> R? ): List<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> LongArray.sortedByDescending(     selector: (Long) -> R? ): List<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun LongArray.sortedDescending(): List<Long> ``` **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.LongArray,%20kotlin.Comparator((kotlin.Long)))/comparator). ``` fun LongArray.sortedWith(     comparator: Comparator<in Long> ): List<Long> ``` **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 array and not contained by the specified collection. ``` infix fun LongArray.subtract(     other: Iterable<Long> ): Set<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun LongArray.sum(): Long ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun LongArray.sumBy(selector: (Long) -> 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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun LongArray.sumByDouble(selector: (Long) -> Double): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.LongArray,%20kotlin.Function1((kotlin.Long,%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 LongArray.sumOf(selector: (Long) -> Double): Double ``` **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 LongArray.sumOf(selector: (Long) -> Long): Long ``` **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 LongArray.sumOf(selector: (Long) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun LongArray.sumOf(     selector: (Long) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun LongArray.sumOf(     selector: (Long) -> BigInteger ): BigInteger ``` **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.LongArray,%20kotlin.Int)/n) elements. ``` fun LongArray.take(n: Int): List<Long> ``` **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.LongArray,%20kotlin.Int)/n) elements. ``` fun LongArray.takeLast(n: Int): List<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.takeLastWhile(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.Function1((kotlin.Long,%20kotlin.Boolean)))/predicate). ``` fun LongArray.takeWhile(     predicate: (Long) -> Boolean ): List<Long> ``` **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.LongArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Long>> LongArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun LongArray.toCValues(): CValues<LongVar> ``` **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 LongArray.toHashSet(): HashSet<Long> ``` **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 LongArray.toList(): List<Long> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun LongArray.toMutableList(): MutableList<Long> ``` **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 array. ``` fun LongArray.toMutableSet(): MutableSet<Long> ``` **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 LongArray.toSet(): Set<Long> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun LongArray.toSortedSet(): SortedSet<Long> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toULongArray](../../kotlin.collections/to-u-long-array) Returns an array of type [ULongArray](../-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 ``` **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 LongArray.union(other: Iterable<Long>): Set<Long> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun LongArray.withIndex(): Iterable<IndexedValue<Long>> ``` **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.LongArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Long, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.LongArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Long,%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.LongArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Long,%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> LongArray.zip(     other: Array<out R>,     transform: (a: Long, 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.LongArray,%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> LongArray.zip(     other: Iterable<R> ): List<Pair<Long, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.LongArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Long,%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.LongArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Long,%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> LongArray.zip(     other: Iterable<R>,     transform: (a: Long, 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.LongArray,%20kotlin.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.LongArray,%20kotlin.LongArray,%20kotlin.Function2((kotlin.Long,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> LongArray.zip(     other: LongArray,     transform: (a: Long, b: Long) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): LongIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Long) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.LongArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.LongArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Long) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/index) to the given [value](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/value). This method can be called using the index operator. If the [index](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/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. ##### For Native Sets the element at the given [index](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/index) to the given [value](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/value). This method can be called using the index operator. If the [index](set#kotlin.LongArray%24set(kotlin.Int,%20kotlin.Long)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [LongArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Long ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.LongArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.LongArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.LongArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.LongArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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 UByte in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toInt(): Int ``` Converts this [UByte](index) value to [Int](../-int/index#kotlin.Int). The resulting `Int` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `Int` value are the same as the bits of this `UByte` value, whereas the most significant 24 bits are filled with zeros. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toByte(): Byte ``` Converts this [UByte](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 `UByte`. Otherwise the result is negative. The resulting `Byte` value has the same binary representation as this `UByte` value. kotlin UByte UByte ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) ``` inline class UByte : Comparable<UByte> ``` 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: UByte): UByte ``` **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(): UByte ``` **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(): UByte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <inv> Inverts the bits in this value. ``` fun inv(): UByte ``` **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: UByte): UByte ``` **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.UByte%24rangeTo(kotlin.UByte)/other) value. ``` operator fun rangeTo(other: UByte): 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.UByte%24rangeUntil(kotlin.UByte)/other) value. ``` operator fun rangeUntil(other: UByte): 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 [UByte](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 [UByte](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 [UByte](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 [UByte](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 [UByte](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 [UByte](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) Returns this value. ``` fun toUByte(): UByte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toUInt](to-u-int) Converts this [UByte](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 [UByte](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 [UByte](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: UByte): UByte ``` 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 UByte can have. ``` const val MAX_VALUE: UByte ``` **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 UByte can have. ``` const val MIN_VALUE: UByte ``` **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 UByte 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 UByte 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.UByte,%20kotlin.UByte)/minimumValue). ``` fun UByte.coerceAtLeast(minimumValue: UByte): UByte ``` ``` 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.UByte,%20kotlin.UByte)/maximumValue). ``` fun UByte.coerceAtMost(maximumValue: UByte): UByte ``` ``` 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.UByte,%20kotlin.UByte,%20kotlin.UByte)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.UByte,%20kotlin.UByte,%20kotlin.UByte)/maximumValue). ``` fun UByte.coerceIn(     minimumValue: UByte,     maximumValue: UByte ): UByte ``` ``` 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> UByte.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 [UByte](index) number. ``` fun UByte.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 [UByte](index) number. ``` fun UByte.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 [UByte](index) number. ``` fun UByte.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.UByte,%20kotlin.UByte)/to) value with the step -1. ``` infix fun UByte.downTo(to: UByte): 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 [UByte](index) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.UByte,%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 UByte.rotateLeft(bitCount: Int): UByte ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [UByte](index) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.UByte,%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 UByte.rotateRight(bitCount: Int): UByte ``` **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 [UByte](index) number, or zero, if this number is zero. ``` fun UByte.takeHighestOneBit(): UByte ``` **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 [UByte](index) number, or zero, if this number is zero. ``` fun UByte.takeLowestOneBit(): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toString](../../kotlin.text/to-string) Returns a string representation of this [Byte](../-byte/index#kotlin.Byte) value in the specified [radix](../../kotlin.text/to-string#kotlin.text%24toString(kotlin.UByte,%20kotlin.Int)/radix). ``` fun UByte.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.UByte,%20kotlin.UByte)/to) value. ``` infix fun UByte.until(to: UByte): UIntRange ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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 UByte in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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: UByte ``` A constant holding the minimum value an instance of UByte can have. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toLong(): Long ``` Converts this [UByte](index) value to [Long](../-long/index#kotlin.Long). The resulting `Long` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `Long` value are the same as the bits of this `UByte` value, whereas the most significant 56 bits are filled with zeros. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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: UByte ``` A constant holding the maximum value an instance of UByte can have. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [rangeTo](range-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun rangeTo(other: UByte): UIntRange ``` Creates a range from this value to the specified [other](range-to#kotlin.UByte%24rangeTo(kotlin.UByte)/other) value. kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [rangeUntil](range-until) **Platform and version requirements:** JVM (1.7), JS (1.7), Native (1.7) ``` @ExperimentalStdlibApi operator fun rangeUntil(     other: UByte ): UIntRange ``` Creates a range from this value up to but excluding the specified [other](range-until#kotlin.UByte%24rangeUntil(kotlin.UByte)/other) value. If the [other](range-until#kotlin.UByte%24rangeUntil(kotlin.UByte)/other) value is less than or equal to `this` value, then the returned range is empty. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toDouble(): Double ``` Converts this [UByte](index) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `UByte`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun dec(): UByte ``` 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) / [UByte](index) / <and> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun and(other: UByte): UByte ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun inc(): UByte ``` 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) / [UByte](index) / <inv> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun inv(): UByte ``` Inverts the bits in this value. kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [toUInt](to-u-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUInt(): UInt ``` Converts this [UByte](index) value to [UInt](../-u-int/index). The resulting `UInt` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `UInt` value are the same as the bits of this `UByte` value, whereas the most significant 24 bits are filled with zeros. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / <xor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun xor(other: UByte): UByte ``` Performs a bitwise XOR operation between the two values. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](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) / [UByte](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toFloat(): Float ``` Converts this [UByte](index) value to [Float](../-float/index#kotlin.Float). The resulting `Float` value represents the same numerical value as this `UByte`. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [toUByte](to-u-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUByte(): UByte ``` Returns this value. kotlin floorDiv floorDiv ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toShort(): Short ``` Converts this [UByte](index) value to [Short](../-short/index#kotlin.Short). The resulting `Short` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `Short` value are the same as the bits of this `UByte` value, whereas the most significant 8 bits are filled with zeros. kotlin toULong toULong ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / [toULong](to-u-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toULong(): ULong ``` Converts this [UByte](index) value to [ULong](../-u-long/index). The resulting `ULong` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `ULong` value are the same as the bits of this `UByte` value, whereas the most significant 56 bits are filled with zeros. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](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) / [UByte](index) / <or> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` infix fun or(other: UByte): UByte ``` Performs a bitwise OR operation between the two values. kotlin toUShort toUShort ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UByte](index) / [toUShort](to-u-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toUShort(): UShort ``` Converts this [UByte](index) value to [UShort](../-u-short/index). The resulting `UShort` value represents the same numerical value as this `UByte`. The least significant 8 bits of the resulting `UShort` value are the same as the bits of this `UByte` value, whereas the most significant 8 bits are filled with zeros. kotlin KotlinVersion KotlinVersion ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` class KotlinVersion : Comparable<KotlinVersion> ``` Represents a version of the Kotlin standard library. <major>, <minor> and <patch> are integer components of a version, they must be non-negative and not greater than 255 ([MAX\_COMPONENT\_VALUE](-m-a-x_-c-o-m-p-o-n-e-n-t_-v-a-l-u-e)). Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a version from major and minor components, leaving <patch> component zero. ``` KotlinVersion(major: Int, minor: Int) ``` Creates a version from all three components. ``` KotlinVersion(major: Int, minor: Int, patch: Int) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <major> ``` val major: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <minor> ``` val minor: Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <patch> ``` val patch: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) ``` fun compareTo(other: KotlinVersion): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** 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) #### [isAtLeast](is-at-least) Returns `true` if this version is not less than the version specified with the provided [major](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int)/major) and [minor](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int)/minor) components. ``` fun isAtLeast(major: Int, minor: Int): Boolean ``` Returns `true` if this version is not less than the version specified with the provided [major](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/major), [minor](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/minor) and [patch](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/patch) components. ``` fun isAtLeast(major: Int, minor: Int, patch: Int): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns the string representation of this version ``` fun toString(): String ``` Companion Object Properties --------------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [CURRENT](-c-u-r-r-e-n-t) Returns the current version of the Kotlin standard library. ``` val CURRENT: KotlinVersion ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [MAX\_COMPONENT\_VALUE](-m-a-x_-c-o-m-p-o-n-e-n-t_-v-a-l-u-e) Maximum value a version component can have, a constant value 255. ``` const val MAX_COMPONENT_VALUE: 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** 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> ``` kotlin patch patch ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / <patch> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val patch: Int ``` kotlin isAtLeast isAtLeast ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / [isAtLeast](is-at-least) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isAtLeast(major: Int, minor: Int): Boolean ``` Returns `true` if this version is not less than the version specified with the provided [major](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int)/major) and [minor](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int)/minor) components. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun isAtLeast(major: Int, minor: Int, patch: Int): Boolean ``` Returns `true` if this version is not less than the version specified with the provided [major](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/major), [minor](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/minor) and [patch](is-at-least#kotlin.KotlinVersion%24isAtLeast(kotlin.Int,%20kotlin.Int,%20kotlin.Int)/patch) components.
programming_docs
kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun compareTo(other: KotlinVersion): Int ``` kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](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](../index) / [KotlinVersion](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns the string representation of this version kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` KotlinVersion(major: Int, minor: Int) ``` Creates a version from major and minor components, leaving <patch> component zero. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` KotlinVersion(major: Int, minor: Int, patch: Int) ``` Creates a version from all three components. **Constructor** Creates a version from all three components. kotlin minor minor ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / <minor> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val minor: Int ``` kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](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. kotlin CURRENT CURRENT ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / [CURRENT](-c-u-r-r-e-n-t) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val CURRENT: KotlinVersion ``` Returns the current version of the Kotlin standard library. kotlin MAX_COMPONENT_VALUE MAX\_COMPONENT\_VALUE ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / [MAX\_COMPONENT\_VALUE](-m-a-x_-c-o-m-p-o-n-e-n-t_-v-a-l-u-e) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` const val MAX_COMPONENT_VALUE: Int ``` Maximum value a version component can have, a constant value 255. kotlin major major ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinVersion](index) / <major> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val major: Int ``` kotlin Pair Pair ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Pair](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` data class Pair<out A, out B> : Serializable ``` Represents a generic pair of two values. There is no meaning attached to values in this class, it can be used for any purpose. Pair exhibits value semantics, i.e. two pairs are equal if both components are equal. An example of decomposing it into values: ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val (a, b) = Pair(1, "x") println(a) // 1 println(b) // x //sampleEnd } ``` Parameters ---------- `A` - type of the first value. `B` - type of the second value. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new instance of Pair. ``` Pair(first: A, second: B) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> First value. ``` val first: A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <second> Second value. ``` val second: B ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns string representation of the [Pair](index) including its [first](../../kotlin.collections/first) and <second> values. ``` fun toString(): String ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Converts this pair into a list. ``` fun <T> Pair<T, T>.toList(): List<T> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Pair](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns string representation of the [Pair](index) including its [first](../../kotlin.collections/first) and <second> values. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Pair](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` Pair(first: A, second: B) ``` Creates a new instance of Pair. **Constructor** Creates a new instance of Pair. kotlin second second ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Pair](index) / <second> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val second: B ``` Second value. Property -------- `second` - Second value. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Pair](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: A ``` First value. Property -------- `first` - First value. kotlin ExperimentalSubclassOptIn ExperimentalSubclassOptIn ========================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalSubclassOptIn](index) **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) ``` @Target([AnnotationTarget.CLASS]) annotation class ExperimentalSubclassOptIn ``` This annotation marks the experimental preview of the language feature [SubclassOptInRequired](../-subclass-opt-in-required/index). Note that this API is in a preview state and has a chance of being changed in the future. Do not use it if you develop a library since your library can become source incompatible with the future versions of Kotlin. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) This annotation marks the experimental preview of the language feature [SubclassOptInRequired](../-subclass-opt-in-required/index). ``` ExperimentalSubclassOptIn() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ExperimentalSubclassOptIn](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` ExperimentalSubclassOptIn() ``` This annotation marks the experimental preview of the language feature [SubclassOptInRequired](../-subclass-opt-in-required/index). Note that this API is in a preview state and has a chance of being changed in the future. Do not use it if you develop a library since your library can become source incompatible with the future versions of Kotlin. kotlin BuilderInference BuilderInference ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BuilderInference](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @Target([AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY]) @ExperimentalTypeInference annotation class BuilderInference ``` Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. When this annotation is placed on a generic function parameter of a function, it enables to infer the type arguments of that generic function from the lambda body passed to that parameter. The calls that affect inference are either members of the receiver type of an annotated function parameter or extensions for that type. The extensions must be themselves annotated with `@BuilderInference`. Example: we declare ``` fun <T> sequence(@BuilderInference block: suspend SequenceScope<T>.() -> Unit): Sequence<T> ``` and use it like ``` val result = sequence { yield("result") } ``` Here the type argument of the resulting sequence is inferred to `String` from the argument of the [SequenceScope.yield](../../kotlin.sequences/-sequence-scope/yield) function, that is called inside the lambda passed to [sequence](../../kotlin.sequences/sequence). 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-) Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. ``` BuilderInference() ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BuilderInference](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` BuilderInference() ``` Allows to infer generic type arguments of a function from the calls in the annotated function parameter of that function. When this annotation is placed on a generic function parameter of a function, it enables to infer the type arguments of that generic function from the lambda body passed to that parameter. The calls that affect inference are either members of the receiver type of an annotated function parameter or extensions for that type. The extensions must be themselves annotated with `@BuilderInference`. Example: we declare ``` fun <T> sequence(@BuilderInference block: suspend SequenceScope<T>.() -> Unit): Sequence<T> ``` and use it like ``` val result = sequence { yield("result") } ``` Here the type argument of the resulting sequence is inferred to `String` from the argument of the [SequenceScope.yield](../../kotlin.sequences/-sequence-scope/yield) function, that is called inside the lambda passed to [sequence](../../kotlin.sequences/sequence). Note: this annotation is experimental, see [ExperimentalTypeInference](../../kotlin.experimental/-experimental-type-inference/index) on how to opt-in for it. kotlin KotlinNullPointerException KotlinNullPointerException ========================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [KotlinNullPointerException](index) **Platform and version requirements:** JVM (1.0) ``` open class KotlinNullPointerException : NullPointerException ``` Constructors ------------ **Platform and version requirements:** JVM (1.0) #### [<init>](-init-) ``` KotlinNullPointerException() ``` ``` KotlinNullPointerException(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:** 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) / [KotlinNullPointerException](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0) ``` KotlinNullPointerException() ``` ``` KotlinNullPointerException(message: String?) ``` kotlin Triple Triple ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` data class Triple<out A, out B, out C> : Serializable ``` Represents a triad of values There is no meaning attached to values in this class, it can be used for any purpose. Triple exhibits value semantics, i.e. two triples are equal if all three components are equal. An example of decomposing it into values: ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val (a, b, c) = Triple(2, "x", listOf(null)) println(a) // 2 println(b) // x println(c) // [null] //sampleEnd } ``` Parameters ---------- `A` - type of the first value. `B` - type of the second value. `C` - type of the third value. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Represents a triad of values ``` Triple(first: A, second: B, third: C) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <first> First value. ``` val first: A ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <second> Second value. ``` val second: B ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <third> Third value. ``` val third: C ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toString](to-string) Returns string representation of the [Triple](index) including its [first](../../kotlin.collections/first), <second> and <third> values. ``` fun toString(): String ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toList](../to-list) Converts this triple into a list. ``` fun <T> Triple<T, T, T>.toList(): List<T> ``` kotlin toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) / [toString](to-string) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun toString(): String ``` Returns string representation of the [Triple](index) including its [first](../../kotlin.collections/first), <second> and <third> values. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` Triple(first: A, second: B, third: C) ``` Represents a triad of values There is no meaning attached to values in this class, it can be used for any purpose. Triple exhibits value semantics, i.e. two triples are equal if all three components are equal. An example of decomposing it into values: ``` import kotlin.test.* fun main(args: Array<String>) { //sampleStart val (a, b, c) = Triple(2, "x", listOf(null)) println(a) // 2 println(b) // x println(c) // [null] //sampleEnd } ``` Parameters ---------- `A` - type of the first value. `B` - type of the second value. `C` - type of the third value. kotlin third third ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) / <third> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val third: C ``` Third value. Property -------- `third` - Third value. kotlin second second ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) / <second> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val second: B ``` Second value. Property -------- `second` - Second value. kotlin first first ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Triple](index) / <first> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val first: A ``` First value. Property -------- `first` - First value. kotlin contains contains ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](index) / <contains> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun contains(element: UShort): Boolean ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](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 UShortArray UShortArray =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](index) **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) ``` @ExperimentalUnsignedTypes inline class UShortArray :      Collection<UShort> ``` 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. ``` UShortArray(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: UShort): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [containsAll](contains-all) ``` fun containsAll(elements: Collection<UShort>): 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.UShortArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): UShort ``` **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<UShort> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.UShortArray%24set(kotlin.Int,%20kotlin.UShort)/index) to the given [value](set#kotlin.UShortArray%24set(kotlin.Int,%20kotlin.UShort)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: UShort) ``` 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 UShortArray.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 UShortArray.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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.all(predicate: (UShort) -> 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 UShortArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.any(predicate: (UShort) -> 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.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.3), JS (1.3), Native (1.3) #### [asShortArray](../../kotlin.collections/as-short-array) Returns an array of type [ShortArray](../-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](../../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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> UShortArray.associateWith(     valueSelector: (UShort) -> V ): Map<UShort, 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.UShortArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UShort,%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.UShortArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in UShort, in V>> UShortArray.associateWithTo(     destination: M,     valueSelector: (UShort) -> 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.UShortArray,%20kotlin.UShort,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun UShortArray.binarySearch(     element: UShort,     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 UShortArray.component1(): UShort ``` **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 UShortArray.component2(): UShort ``` **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 UShortArray.component3(): UShort ``` **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 UShortArray.component4(): UShort ``` **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 UShortArray.component5(): UShort ``` **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 UShortArray.contentEquals(     other: UShortArray ): Boolean ``` ``` infix fun UShortArray?.contentEquals(     other: UShortArray? ): 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 UShortArray.contentHashCode(): Int ``` ``` fun UShortArray?.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 UShortArray.contentToString(): String ``` ``` fun UShortArray?.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.UShortArray,%20kotlin.UShortArray,%20kotlin.Int,%20kotlin.Int,%20kotlin.Int)/destination) array and returns that array. ``` fun UShortArray.copyInto(     destination: UShortArray,     destinationOffset: Int = 0,     startIndex: Int = 0,     endIndex: Int = size ): UShortArray ``` **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 UShortArray.copyOf(): UShortArray ``` Returns new array which is a copy of the original array, resized to the given [newSize](../../kotlin.collections/copy-of#kotlin.collections%24copyOf(kotlin.UShortArray,%20kotlin.Int)/newSize). The copy is either truncated or padded at the end with zero values if necessary. ``` fun UShortArray.copyOf(newSize: Int): UShortArray ``` **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 UShortArray.copyOfRange(     fromIndex: Int,     toIndex: Int ): UShortArray ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.count(predicate: (UShort) -> 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.UShortArray,%20kotlin.Int)/n) elements. ``` fun UShortArray.drop(n: Int): List<UShort> ``` **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.UShortArray,%20kotlin.Int)/n) elements. ``` fun UShortArray.dropLast(n: Int): List<UShort> ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.dropLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.dropWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` ``` 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.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/index) is out of bounds of this array. ``` fun UShortArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` 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.UShortArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.UShortArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UShortArray.elementAtOrNull(index: Int): UShort? ``` **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.UShortArray,%20kotlin.UShort,%20kotlin.Int,%20kotlin.Int)/element) value. ``` fun UShortArray.fill(     element: UShort,     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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.filter(     predicate: (UShort) -> Boolean ): List<UShort> ``` ``` 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.UShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.filterIndexed(     predicate: (index: Int, UShort) -> Boolean ): List<UShort> ``` ``` 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.UShortArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.UShortArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UShort>> UShortArray.filterIndexedTo(     destination: C,     predicate: (index: Int, UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.filterNot(     predicate: (UShort) -> Boolean ): List<UShort> ``` ``` 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.UShortArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.UShortArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UShort>> UShortArray.filterNotTo(     destination: C,     predicate: (UShort) -> 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.UShortArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.UShortArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in UShort>> UShortArray.filterTo(     destination: C,     predicate: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UShortArray.find(predicate: (UShort) -> Boolean): UShort? ``` ``` 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UShortArray.findLast(     predicate: (UShort) -> Boolean ): UShort? ``` ``` 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 UShortArray.first(): UShort ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.first(predicate: (UShort) -> Boolean): UShort ``` ``` 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 UShortArray.firstOrNull(): UShort? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun UShortArray.firstOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` ``` 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> UShortArray.flatMap(     transform: (UShort) -> 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.UShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> UShortArray.flatMapIndexed(     transform: (index: Int, UShort) -> 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.UShortArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%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.UShortArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` 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](../../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.UShortArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UShort,%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.UShortArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> UShortArray.flatMapTo(     destination: C,     transform: (UShort) -> 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.UShortArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UShort,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.UShortArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.UShort,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> UShortArray.fold(     initial: R,     operation: (acc: R, UShort) -> 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.UShortArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UShort,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.UShortArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.UShort,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> UShortArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, UShort) -> 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.UShortArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UShort,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.UShortArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.UShort,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> UShortArray.foldRight(     initial: R,     operation: (UShort, 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.UShortArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.UShortArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%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> UShortArray.foldRightIndexed(     initial: R,     operation: (index: Int, UShort, 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Unit)))/action) on each element. ``` fun UShortArray.forEach(action: (UShort) -> 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.UShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun UShortArray.forEachIndexed(     action: (index: Int, UShort) -> 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.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.UShortArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.UShort)))/index) is out of bounds of this array. ``` fun UShortArray.getOrElse(     index: Int,     defaultValue: (Int) -> UShort ): UShort ``` **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.UShortArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.UShortArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun UShortArray.getOrNull(index: Int): UShort? ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%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> UShortArray.groupBy(     keySelector: (UShort) -> K ): Map<K, List<UShort>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UShort,%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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.UShort,%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> 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](../../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.UShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<UShort>>> UShortArray.groupByTo(     destination: M,     keySelector: (UShort) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UShort,%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.UShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.UShortArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.UShort,%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>>> 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](../../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.UShortArray,%20kotlin.UShort)/element), or -1 if the array does not contain element. ``` fun UShortArray.indexOf(element: UShort): 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UShortArray.indexOfFirst(     predicate: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun UShortArray.indexOfLast(     predicate: (UShort) -> 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 UShortArray.last(): UShort ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.last(predicate: (UShort) -> Boolean): UShort ``` ``` 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.UShortArray,%20kotlin.UShort)/element), or -1 if the array does not contain element. ``` fun UShortArray.lastIndexOf(element: UShort): 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 UShortArray.lastOrNull(): UShort? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun UShortArray.lastOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` ``` 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> UShortArray.map(transform: (UShort) -> 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.UShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> UShortArray.mapIndexed(     transform: (index: Int, UShort) -> 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.UShortArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%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.UShortArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UShortArray.mapIndexedTo(     destination: C,     transform: (index: Int, UShort) -> 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.UShortArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UShort,%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.UShortArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> UShortArray.mapTo(     destination: C,     transform: (UShort) -> 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>> UShortArray.maxByOrNull(     selector: (UShort) -> R ): UShort? ``` ``` 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UShortArray.maxOf(selector: (UShort) -> Double): Double ``` ``` fun UShortArray.maxOf(selector: (UShort) -> Float): Float ``` ``` fun <R : Comparable<R>> UShortArray.maxOf(     selector: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UShortArray.maxOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` fun UShortArray.maxOfOrNull(     selector: (UShort) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UShortArray.maxOfOrNull(     selector: (UShort) -> 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.UShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.UShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UShortArray.maxOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> 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.UShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.UShortArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UShortArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> 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 UShortArray.maxOrNull(): UShort? ``` #### [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.UShortArray,%20kotlin.Comparator((kotlin.UShort)))/comparator). ``` fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort ``` ``` fun <T> Iterable<T>.maxWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UShortArray.maxWith(     comparator: Comparator<in UShort> ): UShort? ``` **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.UShortArray,%20kotlin.Comparator((kotlin.UShort)))/comparator) or `null` if there are no elements. ``` fun UShortArray.maxWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` ``` 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>> UShortArray.minByOrNull(     selector: (UShort) -> R ): UShort? ``` ``` 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UShortArray.minOf(selector: (UShort) -> Double): Double ``` ``` fun UShortArray.minOf(selector: (UShort) -> Float): Float ``` ``` fun <R : Comparable<R>> UShortArray.minOf(     selector: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun UShortArray.minOfOrNull(     selector: (UShort) -> Double ): Double? ``` ``` fun UShortArray.minOfOrNull(     selector: (UShort) -> Float ): Float? ``` ``` fun <R : Comparable<R>> UShortArray.minOfOrNull(     selector: (UShort) -> 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.UShortArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.UShortArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> UShortArray.minOfWith(     comparator: Comparator<in R>,     selector: (UShort) -> 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.UShortArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.UShortArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.UShort,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> UShortArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (UShort) -> 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 UShortArray.minOrNull(): UShort? ``` **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.UShortArray,%20kotlin.Comparator((kotlin.UShort)))/comparator). ``` fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort ``` ``` fun <T> Iterable<T>.minWith(comparator: Comparator<in T>): T ``` **Platform and version requirements:** JVM (1.3) ``` fun UShortArray.minWith(     comparator: Comparator<in UShort> ): UShort? ``` **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.UShortArray,%20kotlin.Comparator((kotlin.UShort)))/comparator) or `null` if there are no elements. ``` fun UShortArray.minWithOrNull(     comparator: Comparator<in UShort> ): UShort? ``` ``` 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 UShortArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.none(predicate: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun UShortArray.onEach(action: (UShort) -> Unit): UShortArray ``` 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.UShortArray,%20kotlin.Function2((kotlin.Int,%20kotlin.UShort,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun UShortArray.onEachIndexed(     action: (index: Int, UShort) -> Unit ): UShortArray ``` 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.UShortArray,%20kotlin.UShort)/element). ``` operator fun UShortArray.plus(element: UShort): UShortArray ``` 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.UShortArray,%20kotlin.collections.Collection((kotlin.UShort)))/elements) collection. ``` 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](../../kotlin.collections/plus#kotlin.collections%24plus(kotlin.UShortArray,%20kotlin.UShortArray)/elements) array. ``` operator fun UShortArray.plus(     elements: UShortArray ): UShortArray ``` 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 UShortArray.random(): UShort ``` Returns a random element from this array using the specified source of randomness. ``` fun UShortArray.random(random: Random): UShort ``` **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 UShortArray.randomOrNull(): UShort? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun UShortArray.randomOrNull(random: Random): UShort? ``` **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.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UShortArray.reduce(     operation: (acc: UShort, UShort) -> UShort ): UShort ``` ``` 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.UShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UShortArray.reduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort ``` 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.UShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun UShortArray.reduceIndexedOrNull(     operation: (index: Int, acc: UShort, UShort) -> UShort ): UShort? ``` 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.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun UShortArray.reduceOrNull(     operation: (acc: UShort, UShort) -> UShort ): UShort? ``` ``` 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.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UShortArray.reduceRight(     operation: (UShort, acc: UShort) -> UShort ): UShort ``` **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.UShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UShortArray.reduceRightIndexed(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort ``` **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.UShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun UShortArray.reduceRightIndexedOrNull(     operation: (index: Int, UShort, acc: UShort) -> UShort ): UShort? ``` **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.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun UShortArray.reduceRightOrNull(     operation: (UShort, acc: UShort) -> UShort ): UShort? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun UShortArray.refTo(index: Int): CValuesRef<UShortVar> ``` **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 UShortArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun UShortArray.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 UShortArray.reversed(): List<UShort> ``` **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 UShortArray.reversedArray(): UShortArray ``` **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.UShortArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UShort,%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.UShortArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.UShort,%20)))/initial) value. ``` fun <R> UShortArray.runningFold(     initial: R,     operation: (acc: R, UShort) -> 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.UShortArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UShort,%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.UShortArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.UShort,%20)))/initial) value. ``` 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](../../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.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun UShortArray.runningReduce(     operation: (acc: UShort, UShort) -> UShort ): List<UShort> ``` 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.UShortArray,%20kotlin.Function3((kotlin.Int,%20kotlin.UShort,%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 UShortArray.runningReduceIndexed(     operation: (index: Int, acc: UShort, UShort) -> UShort ): List<UShort> ``` 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.UShortArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UShort,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.UShortArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.UShort,%20)))/initial) value. ``` fun <R> UShortArray.scan(     initial: R,     operation: (acc: R, UShort) -> 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.UShortArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UShort,%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.UShortArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.UShort,%20)))/initial) value. ``` 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](../../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 UShortArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.UShortArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun UShortArray.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 UShortArray.single(): UShort ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun UShortArray.single(     predicate: (UShort) -> Boolean ): UShort ``` ``` 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 UShortArray.singleOrNull(): UShort? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun UShortArray.singleOrNull(     predicate: (UShort) -> Boolean ): UShort? ``` ``` 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.UShortArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UShortArray.slice(indices: IntRange): List<UShort> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.UShortArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun UShortArray.slice(indices: Iterable<Int>): List<UShort> ``` **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.UShortArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun UShortArray.sliceArray(     indices: Collection<Int> ): UShortArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.UShortArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun UShortArray.sliceArray(indices: IntRange): UShortArray ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [sort](../../kotlin.collections/sort) Sorts the array in-place. ``` fun UShortArray.sort() ``` Sorts a range in the array in-place. ``` fun UShortArray.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 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 UShortArray.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 UShortArray.sorted(): List<UShort> ``` **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 UShortArray.sortedArray(): UShortArray ``` **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 UShortArray.sortedArrayDescending(): UShortArray ``` **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 UShortArray.sortedDescending(): List<UShort> ``` **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 UShortArray.sum(): UInt ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.UInt)))/selector) function applied to each element in the array. ``` fun UShortArray.sumBy(selector: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun UShortArray.sumByDouble(     selector: (UShort) -> 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.UShortArray,%20kotlin.Function1((kotlin.UShort,%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 UShortArray.sumOf(selector: (UShort) -> Double): Double ``` **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 UShortArray.sumOf(selector: (UShort) -> Long): Long ``` **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 UShortArray.sumOf(selector: (UShort) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun UShortArray.sumOf(     selector: (UShort) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun UShortArray.sumOf(     selector: (UShort) -> 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.UShortArray,%20kotlin.Int)/n) elements. ``` fun UShortArray.take(n: Int): List<UShort> ``` **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.UShortArray,%20kotlin.Int)/n) elements. ``` fun UShortArray.takeLast(n: Int): List<UShort> ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.takeLastWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` **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.UShortArray,%20kotlin.Function1((kotlin.UShort,%20kotlin.Boolean)))/predicate). ``` fun UShortArray.takeWhile(     predicate: (UShort) -> Boolean ): List<UShort> ``` ``` 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 UShortArray.toCValues(): CValues<UShortVar> ``` **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) #### [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) #### [toShortArray](../../kotlin.collections/to-short-array) Returns an array of type [ShortArray](../-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.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 UShortArray.toTypedArray(): Array<UShort> ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUShortArray](../../kotlin.collections/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](../../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 UShortArray.withIndex(): Iterable<IndexedValue<UShort>> ``` **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.UShortArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> UShortArray.zip(     other: Array<out R> ): List<Pair<UShort, R>> ``` ``` 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](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UShortArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UShort,%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.UShortArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UShort,%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> 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](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UShortArray,%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> UShortArray.zip(     other: Iterable<R> ): List<Pair<UShort, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UShortArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UShort,%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.UShortArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.UShort,%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> 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](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UShortArray,%20kotlin.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.UShortArray,%20kotlin.UShortArray,%20kotlin.Function2((kotlin.UShort,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` 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](../../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) / [UShortArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun iterator(): Iterator<UShort> ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` UShortArray(size: Int) ``` Creates a new array of the specified size, with all elements initialized to zero. kotlin containsAll containsAll =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](index) / [containsAll](contains-all) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` fun containsAll(elements: Collection<UShort>): Boolean ``` kotlin isEmpty isEmpty ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [UShortArray](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) / [UShortArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun set(index: Int, value: UShort) ``` Sets the element at the given [index](set#kotlin.UShortArray%24set(kotlin.Int,%20kotlin.UShort)/index) to the given [value](set#kotlin.UShortArray%24set(kotlin.Int,%20kotlin.UShort)/value). This method can be called using the index operator. If the [index](set#kotlin.UShortArray%24set(kotlin.Int,%20kotlin.UShort)/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) / [UShortArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun get(index: Int): UShort ``` Returns the array element at the given [index](get#kotlin.UShortArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.UShortArray%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 SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [SIZE\_BITS](-s-i-z-e_-b-i-t-s) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` const val SIZE_BITS: Int ``` The number of bits used to represent an instance of Float in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Converts this [Float](index#kotlin.Float) value to [Int](../-int/index#kotlin.Int). The fractional part, if any, is rounded down towards zero. Returns zero if this `Float` value is `NaN`, [Int.MIN\_VALUE](../-int/-m-i-n_-v-a-l-u-e#kotlin.Int.Companion%24MIN_VALUE) if it's less than `Int.MIN_VALUE`, [Int.MAX\_VALUE](../-int/-m-a-x_-v-a-l-u-e#kotlin.Int.Companion%24MAX_VALUE) if it's bigger than `Int.MAX_VALUE`. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.3", "1.5") fun toByte(): Byte ``` **Deprecated:** Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte. Converts this [Float](index#kotlin.Float) value to [Byte](../-byte/index#kotlin.Byte). The resulting `Byte` value is equal to `this.toInt().toByte()`. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Float ``` Returns this value. kotlin NaN NaN === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [NaN](-na-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val NaN: Float ``` A constant holding the "not a number" value of Float. kotlin Float Float ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Float : Number, Comparable<Float> ``` ##### For Common, JVM, JS 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`. ##### For Native Represents a single-precision 32-bit IEEE 754 floating point number. Functions --------- **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(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <div> Divides this value by the other value. ``` operator fun div(other: Byte): Float ``` ``` operator fun div(other: Short): Float ``` ``` operator fun div(other: Int): Float ``` ``` operator fun div(other: Long): Float ``` ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Float): 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(): Float ``` **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): Float ``` ``` operator fun minus(other: Short): Float ``` ``` operator fun minus(other: Int): Float ``` ``` operator fun minus(other: Long): Float ``` ``` 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) #### <plus> Adds the other value to this value. ``` operator fun plus(other: Byte): Float ``` ``` operator fun plus(other: Short): Float ``` ``` operator fun plus(other: Int): Float ``` ``` operator fun plus(other: Long): Float ``` ``` operator fun plus(other: Float): Float ``` ``` operator fun plus(other: Double): Double ``` **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): Float ``` ``` operator fun rem(other: Short): Float ``` ``` operator fun rem(other: Int): Float ``` ``` operator fun rem(other: Long): Float ``` ``` 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) #### <times> Multiplies this value by the other value. ``` operator fun times(other: Byte): Float ``` ``` operator fun times(other: Short): Float ``` ``` operator fun times(other: Int): Float ``` ``` operator fun times(other: Long): Float ``` ``` 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 [Float](index#kotlin.Float) 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 [Float](index#kotlin.Float) 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 [Float](index#kotlin.Float) 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) Returns this value. ``` fun toFloat(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toInt](to-int) Converts this [Float](index#kotlin.Float) 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 [Float](index#kotlin.Float) 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 [Float](index#kotlin.Float) 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(): Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Float ``` 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 largest positive finite value of Float. ``` const val MAX_VALUE: Float ``` **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 smallest *positive* nonzero value of Float. ``` const val MIN_VALUE: Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NaN](-na-n) A constant holding the "not a number" value of Float. ``` const val NaN: Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NEGATIVE\_INFINITY](-n-e-g-a-t-i-v-e_-i-n-f-i-n-i-t-y) A constant holding the negative infinity value of Float. ``` const val NEGATIVE_INFINITY: Float ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [POSITIVE\_INFINITY](-p-o-s-i-t-i-v-e_-i-n-f-i-n-i-t-y) A constant holding the positive infinity value of Float. ``` const val POSITIVE_INFINITY: Float ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [SIZE\_BITS](-s-i-z-e_-b-i-t-s) The number of bits used to represent an instance of Float in a binary form. ``` const val SIZE_BITS: Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) The number of bytes used to represent an instance of Float 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.Float,%20kotlin.Float)/minimumValue). ``` fun Float.coerceAtLeast(minimumValue: Float): Float ``` ``` 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.Float,%20kotlin.Float)/maximumValue). ``` fun Float.coerceAtMost(maximumValue: Float): Float ``` ``` 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.Float,%20kotlin.Float,%20kotlin.Float)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Float,%20kotlin.Float,%20kotlin.Float)/maximumValue). ``` fun Float.coerceIn(     minimumValue: Float,     maximumValue: Float ): Float ``` ``` 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:** 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 Float.mod(other: Float): Float ``` ``` fun Float.mod(other: Double): Double ``` **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 [Float](index#kotlin.Float) value to the specified [that](../../kotlin.ranges/range-to#kotlin.ranges%24rangeTo(kotlin.Float,%20kotlin.Float)/that) value. ``` operator fun Float.rangeTo(     that: Float ): ClosedFloatingPointRange<Float> ``` 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 [Float](index#kotlin.Float) value to the specified [that](../../kotlin.ranges/range-until#kotlin.ranges%24rangeUntil(kotlin.Float,%20kotlin.Float)/that) value. ``` operator fun Float.rangeUntil(     that: Float ): OpenEndRange<Float> ``` 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 [Float](index#kotlin.Float) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Float.toBigDecimal(): BigDecimal ``` ``` fun Float.toBigDecimal(mathContext: MathContext): BigDecimal ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Float](index#kotlin.Float) value to [UInt](../-u-int/index). ``` fun Float.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Float](index#kotlin.Float) value to [ULong](../-u-long/index). ``` fun Float.toULong(): ULong ``` kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of Float in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](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: Float ``` A constant holding the smallest *positive* nonzero value of Float. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Converts this [Float](index#kotlin.Float) value to [Long](../-long/index#kotlin.Long). The fractional part, if any, is rounded down towards zero. Returns zero if this `Float` value is `NaN`, [Long.MIN\_VALUE](../-long/-m-i-n_-v-a-l-u-e#kotlin.Long.Companion%24MIN_VALUE) if it's less than `Long.MIN_VALUE`, [Long.MAX\_VALUE](../-long/-m-a-x_-v-a-l-u-e#kotlin.Long.Companion%24MAX_VALUE) if it's bigger than `Long.MAX_VALUE`. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](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: Float ``` A constant holding the largest positive finite value of Float.
programming_docs
kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](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 rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <rem> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun rem(other: Byte): Float ``` ``` operator fun rem(other: Short): Float ``` ``` operator fun rem(other: Int): Float ``` ``` operator fun rem(other: Long): Float ``` ``` 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 div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Byte): Float ``` ``` operator fun div(other: Short): Float ``` ``` operator fun div(other: Int): Float ``` ``` operator fun div(other: Long): Float ``` ``` 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) / [Float](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Converts this [Float](index#kotlin.Float) value to [Double](../-double/index#kotlin.Double). The resulting `Double` value represents the same numerical value as this `Float`. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Float ``` 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) / [Float](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 NEGATIVE_INFINITY NEGATIVE\_INFINITY ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [NEGATIVE\_INFINITY](-n-e-g-a-t-i-v-e_-i-n-f-i-n-i-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val NEGATIVE_INFINITY: Float ``` A constant holding the negative infinity value of Float. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Float ``` 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) / [Float](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) / [Float](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryMinus(): Float ``` Returns the negative of this value. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](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: Float): Boolean ``` kotlin POSITIVE_INFINITY POSITIVE\_INFINITY ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / [POSITIVE\_INFINITY](-p-o-s-i-t-i-v-e_-i-n-f-i-n-i-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val POSITIVE_INFINITY: Float ``` A constant holding the positive infinity value of Float. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: Byte): Float ``` ``` operator fun times(other: Short): Float ``` ``` operator fun times(other: Int): Float ``` ``` operator fun times(other: Long): Float ``` ``` 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) / [Float](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Returns this value. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Byte): Float ``` ``` operator fun minus(other: Short): Float ``` ``` operator fun minus(other: Int): Float ``` ``` operator fun minus(other: Long): Float ``` ``` 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) / [Float](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.3", "1.5") fun toShort(): Short ``` **Deprecated:** Unclear conversion. To achieve the same result convert to Int explicitly and then to Short. Converts this [Float](index#kotlin.Float) value to [Short](../-short/index#kotlin.Short). The resulting `Short` value is equal to `this.toInt().toShort()`. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Float](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: Byte): Float ``` ``` operator fun plus(other: Short): Float ``` ``` operator fun plus(other: Int): Float ``` ``` operator fun plus(other: Long): Float ``` ``` 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) / [Float](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 [Float](index#kotlin.Float) value to [Char](../-char/index#kotlin.Char). The resulting `Char` value is equal to `this.toInt().toChar()`. kotlin Comparable Comparable ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Comparable](index) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` interface Comparable<in T> ``` Classes which inherit from this interface have a defined total ordering between their instances. Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [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.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). ``` abstract operator fun compareTo(other: T): 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** JVM (1.0), JS (1.0), Native (1.0) #### [rangeTo](../../kotlin.ranges/range-to) Creates a range from this [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](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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Boolean](../-boolean/index) Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are represented as values of the primitive type `boolean`. ``` class Boolean : Comparable<Boolean> ``` **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) #### [Char](../-char/index) Represents a 16-bit Unicode character. ``` class Char : Comparable<Char> ``` **Platform and version requirements:** JVM (1.8), JS (1.8), Native (1.8) #### [ComparableTimeMark](../../kotlin.time/-comparable-time-mark/index) A [TimeMark](../../kotlin.time/-time-mark/index) that can be compared for difference with other time marks obtained from the same [TimeSource.WithComparableMarks](../../kotlin.time/-time-source/-with-comparable-marks/index) time source. ``` interface ComparableTimeMark :      TimeMark,     Comparable<ComparableTimeMark> ``` **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.6), JS (1.6), Native (1.6) #### [Duration](../../kotlin.time/-duration/index) Represents the amount of time one instant of time is away from another instant. ``` class Duration : Comparable<Duration> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [Enum](../-enum/index) The common base class of all enum classes. See the [Kotlin language documentation](../../../../../../docs/enum-classes) for more information on enum classes. ``` abstract class Enum<E : Enum<E>> : Comparable<E> ``` **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.1), JS (1.1), Native (1.1) #### [KotlinVersion](../-kotlin-version/index) Represents a version of the Kotlin standard library. ``` class KotlinVersion : Comparable<KotlinVersion> ``` **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> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [String](../-string/index) The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. ``` class String : Comparable<String>, CharSequence ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UByte](../-u-byte/index) ``` class UByte : Comparable<UByte> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UInt](../-u-int/index) ``` class UInt : Comparable<UInt> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [ULong](../-u-long/index) ``` class ULong : Comparable<ULong> ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [UShort](../-u-short/index) ``` class UShort : Comparable<UShort> ``` kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Comparable](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.1), Native (1.3) ``` abstract operator fun compareTo(other: T): Int ``` Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). kotlin NumberFormatException NumberFormatException ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NumberFormatException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NumberFormatException : IllegalArgumentException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NumberFormatException = NumberFormatException ``` 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> ```
programming_docs
kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NumberFormatException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin shr shr === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <shr> **Platform and version requirements:** JVM (1.2) ``` infix fun BigInteger.shr(n: Int): BigInteger ``` Shifts this value right by the [n](shr#kotlin%24shr(java.math.BigInteger,%20kotlin.Int)/n) number of bits, filling the leftmost bits with copies of the sign bit. kotlin Extensions for java.math.BigInteger Extensions for java.math.BigInteger =================================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) **Platform and version requirements:** JVM (1.2) #### <and> Performs a bitwise AND operation between the two values. ``` infix fun BigInteger.and(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <dec> Enables the use of the `--` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.dec(): BigInteger ``` **Platform and version requirements:** JVM (1.0) #### <div> Enables the use of the `/` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.div(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <inc> Enables the use of the `++` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.inc(): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <inv> Inverts the bits including the sign bit in this value. ``` fun BigInteger.inv(): BigInteger ``` **Platform and version requirements:** JVM (1.0) #### <minus> Enables the use of the `-` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.minus(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <or> Performs a bitwise OR operation between the two values. ``` infix fun BigInteger.or(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.0) #### <plus> Enables the use of the `+` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.plus(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.1) #### <rem> Enables the use of the `%` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.rem(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <shl> Shifts this value left by the [n](shl#kotlin%24shl(java.math.BigInteger,%20kotlin.Int)/n) number of bits. ``` infix fun BigInteger.shl(n: Int): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <shr> Shifts this value right by the [n](shr#kotlin%24shr(java.math.BigInteger,%20kotlin.Int)/n) number of bits, filling the leftmost bits with copies of the sign bit. ``` infix fun BigInteger.shr(n: Int): BigInteger ``` **Platform and version requirements:** JVM (1.0) #### <times> Enables the use of the `*` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.times(other: BigInteger): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](to-big-decimal) Returns the value of this [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun BigInteger.toBigDecimal(): BigDecimal ``` Returns the value of this [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) scaled according to the specified [scale](to-big-decimal#kotlin%24toBigDecimal(java.math.BigInteger,%20kotlin.Int,%20java.math.MathContext)/scale) and rounded according to the settings specified with [mathContext](to-big-decimal#kotlin%24toBigDecimal(java.math.BigInteger,%20kotlin.Int,%20java.math.MathContext)/mathContext). ``` fun BigInteger.toBigDecimal(     scale: Int = 0,     mathContext: MathContext = MathContext.UNLIMITED ): BigDecimal ``` **Platform and version requirements:** JVM (1.0) #### [unaryMinus](unary-minus) Enables the use of the unary `-` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. ``` operator fun BigInteger.unaryMinus(): BigInteger ``` **Platform and version requirements:** JVM (1.2) #### <xor> Performs a bitwise XOR operation between the two values. ``` infix fun BigInteger.xor(other: BigInteger): BigInteger ``` kotlin rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <rem> **Platform and version requirements:** JVM (1.1) ``` operator fun BigInteger.rem(other: BigInteger): BigInteger ``` Enables the use of the `%` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin shl shl === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <shl> **Platform and version requirements:** JVM (1.2) ``` infix fun BigInteger.shl(n: Int): BigInteger ``` Shifts this value left by the [n](shl#kotlin%24shl(java.math.BigInteger,%20kotlin.Int)/n) number of bits. kotlin div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <div> **Platform and version requirements:** JVM (1.0) ``` operator fun BigInteger.div(other: BigInteger): BigInteger ``` Enables the use of the `/` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <dec> **Platform and version requirements:** JVM (1.2) ``` operator fun BigInteger.dec(): BigInteger ``` Enables the use of the `--` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin and and === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <and> **Platform and version requirements:** JVM (1.2) ``` infix fun BigInteger.and(other: BigInteger): BigInteger ``` Performs a bitwise AND operation between the two values. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <inc> **Platform and version requirements:** JVM (1.2) ``` operator fun BigInteger.inc(): BigInteger ``` Enables the use of the `++` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin inv inv === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <inv> **Platform and version requirements:** JVM (1.2) ``` fun BigInteger.inv(): BigInteger ``` Inverts the bits including the sign bit in this value. kotlin unaryMinus unaryMinus ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0) ``` operator fun BigInteger.unaryMinus(): BigInteger ``` Enables the use of the unary `-` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin xor xor === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <xor> **Platform and version requirements:** JVM (1.2) ``` infix fun BigInteger.xor(other: BigInteger): BigInteger ``` Performs a bitwise XOR operation between the two values. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <times> **Platform and version requirements:** JVM (1.0) ``` operator fun BigInteger.times(other: BigInteger): BigInteger ``` Enables the use of the `*` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin minus minus ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <minus> **Platform and version requirements:** JVM (1.0) ``` operator fun BigInteger.minus(other: BigInteger): BigInteger ``` Enables the use of the `-` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <plus> **Platform and version requirements:** JVM (1.0) ``` operator fun BigInteger.plus(other: BigInteger): BigInteger ``` Enables the use of the `+` operator for [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) instances. kotlin toBigDecimal toBigDecimal ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / [toBigDecimal](to-big-decimal) **Platform and version requirements:** JVM (1.2) ``` fun BigInteger.toBigDecimal(): BigDecimal ``` Returns the value of this [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). **Platform and version requirements:** JVM (1.2) ``` fun BigInteger.toBigDecimal(     scale: Int = 0,     mathContext: MathContext = MathContext.UNLIMITED ): BigDecimal ``` Returns the value of this [BigInteger](https://docs.oracle.com/javase/8/docs/api/java/math/BigInteger.html) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html) scaled according to the specified [scale](to-big-decimal#kotlin%24toBigDecimal(java.math.BigInteger,%20kotlin.Int,%20java.math.MathContext)/scale) and rounded according to the settings specified with [mathContext](to-big-decimal#kotlin%24toBigDecimal(java.math.BigInteger,%20kotlin.Int,%20java.math.MathContext)/mathContext). Parameters ---------- `scale` - the scale of the resulting [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html), i.e. number of decimal places of the fractional part. By default 0. kotlin or or == [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [java.math.BigInteger](index) / <or> **Platform and version requirements:** JVM (1.2) ``` infix fun BigInteger.or(other: BigInteger): BigInteger ``` Performs a bitwise OR operation between the two values. kotlin ReplaceWith ReplaceWith =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ReplaceWith](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @Target([]) annotation class ReplaceWith ``` Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. ``` <init>(expression: String, vararg imports: String) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <expression> the replacement expression. The replacement expression is interpreted in the context of the symbol being used, and can reference members of enclosing classes etc. For function calls, the replacement expression may contain argument names of the deprecated function, which will be substituted with actual parameters used in the call being updated. The imports used in the file containing the deprecated function or property are NOT accessible; if the replacement expression refers on any of those imports, they need to be specified explicitly in the [imports](imports#kotlin.ReplaceWith%24imports) parameter. ``` val expression: String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <imports> the qualified names that need to be imported in order for the references in the replacement expression to be resolved correctly. ``` vararg val imports: Array<out String> ``` 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 imports imports ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ReplaceWith](index) / <imports> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` vararg val imports: Array<out String> ``` the qualified names that need to be imported in order for the references in the replacement expression to be resolved correctly. Property -------- `imports` - the qualified names that need to be imported in order for the references in the replacement expression to be resolved correctly. kotlin expression expression ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ReplaceWith](index) / <expression> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val expression: String ``` the replacement expression. The replacement expression is interpreted in the context of the symbol being used, and can reference members of enclosing classes etc. For function calls, the replacement expression may contain argument names of the deprecated function, which will be substituted with actual parameters used in the call being updated. The imports used in the file containing the deprecated function or property are NOT accessible; if the replacement expression refers on any of those imports, they need to be specified explicitly in the [imports](imports#kotlin.ReplaceWith%24imports) parameter. Property -------- `expression` - the replacement expression. The replacement expression is interpreted in the context of the symbol being used, and can reference members of enclosing classes etc. For function calls, the replacement expression may contain argument names of the deprecated function, which will be substituted with actual parameters used in the call being updated. The imports used in the file containing the deprecated function or property are NOT accessible; if the replacement expression refers on any of those imports, they need to be specified explicitly in the [imports](imports#kotlin.ReplaceWith%24imports) parameter. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ReplaceWith](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>(expression: String, vararg imports: String) ``` Specifies a code fragment that can be used to replace a deprecated function, property or class. Tools such as IDEs can automatically apply the replacements specified through this annotation. kotlin IndexOutOfBoundsException IndexOutOfBoundsException ========================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IndexOutOfBoundsException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IndexOutOfBoundsException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IndexOutOfBoundsException = IndexOutOfBoundsException ``` 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> ``` Inheritors ---------- **Platform and version requirements:** Native (1.3) #### [ArrayIndexOutOfBoundsException](../-array-index-out-of-bounds-exception/index) ``` open class ArrayIndexOutOfBoundsException :      IndexOutOfBoundsException ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IndexOutOfBoundsException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin DeprecationLevel DeprecationLevel ================ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecationLevel](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` enum class DeprecationLevel ``` Possible levels of a deprecation. The level specifies how the deprecated element usages are reported in code. **See Also** [Deprecated](../-deprecated/index#kotlin.Deprecated) Enum Values ----------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [WARNING](-w-a-r-n-i-n-g) Usage of the deprecated element will be reported as a warning. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ERROR](-e-r-r-o-r) Usage of the deprecated element will be reported as an error. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [HIDDEN](-h-i-d-d-e-n) Deprecated element will not be accessible from code. Extension Properties -------------------- **Platform and version requirements:** JVM (1.7) #### [declaringJavaClass](../../kotlin.jvm/declaring-java-class) Returns a Java [Class](https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html) instance of the enum the given constant belongs to. ``` val <E : Enum<E>> Enum<E>.declaringJavaClass: Class<E> ``` 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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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:** 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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [ERROR](-e-r-r-o-r) Usage of the deprecated element will be reported as an error. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [HIDDEN](-h-i-d-d-e-n) Deprecated element will not be accessible from code. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [WARNING](-w-a-r-n-i-n-g) Usage of the deprecated element will be reported as a warning.
programming_docs
kotlin WARNING WARNING ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecationLevel](index) / [WARNING](-w-a-r-n-i-n-g) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` WARNING ``` Usage of the deprecated element will be reported as a warning. kotlin ERROR ERROR ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecationLevel](index) / [ERROR](-e-r-r-o-r) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` ERROR ``` Usage of the deprecated element will be reported as an error. kotlin HIDDEN HIDDEN ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DeprecationLevel](index) / [HIDDEN](-h-i-d-d-e-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` HIDDEN ``` Deprecated element will not be accessible from code. kotlin String String ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class String : Comparable<String>, CharSequence ``` The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. ``` <init>() ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <length> Returns the length of this character sequence. ``` val length: Int ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [compareTo](compare-to) Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). ``` fun compareTo(other: String): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <equals> 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:** JVM (1.0), JS (1.0), Native (1.0) #### <get> Returns the character of this string at the specified [index](get#kotlin.String%24get(kotlin.Int)/index). ``` fun get(index: Int): Char ``` **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) #### <plus> Returns a string obtained by concatenating this string with the string representation of the given [other](plus#kotlin.String%24plus(kotlin.Any?)/other) object. ``` operator fun plus(other: Any?): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subSequence](sub-sequence) Returns a new character sequence that is a subsequence of this character sequence, starting at the specified [startIndex](../-char-sequence/sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the specified [endIndex](../-char-sequence/sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/endIndex). ``` fun subSequence(startIndex: Int, endIndex: Int): CharSequence ``` **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 ``` Extension Properties -------------------- **Platform and version requirements:** Native (1.3) #### [cstr](../../kotlinx.cinterop/cstr) ``` val String.cstr: CValues<ByteVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.text/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](../../kotlin.text/last-index) Returns the index of the last character in the char sequence or -1 if it is empty. ``` val CharSequence.lastIndex: Int ``` **Platform and version requirements:** Native (1.3) #### [utf16](../../kotlinx.cinterop/utf16) ``` val String.utf16: CValues<UShortVar> ``` **Platform and version requirements:** Native (1.3) #### [utf32](../../kotlinx.cinterop/utf32) ``` val String.utf32: CValues<IntVar> ``` **Platform and version requirements:** Native (1.3) #### [utf8](../../kotlinx.cinterop/utf8) ``` val String.utf8: CValues<ByteVar> ``` **Platform and version requirements:** Native (1.3) #### [wcstr](../../kotlinx.cinterop/wcstr) ``` val String.wcstr: CValues<UShortVar> ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [all](../../kotlin.text/all) Returns `true` if all characters match the given [predicate](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [asIterable](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate) Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing key-value pairs provided by [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-by-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/associate-with-to) Populates and returns the [destination](../../kotlin.text/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](../../kotlin.text/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) #### [byteInputStream](../../kotlin.io/byte-input-stream) Creates a new byte input stream for the string. ``` fun String.byteInputStream(     charset: Charset = Charsets.UTF_8 ): ByteArrayInputStream ``` **Platform and version requirements:** JVM (1.4) #### [capitalize](../../kotlin.text/capitalize) Returns a copy of this string having its first letter titlecased using the rules of the specified [locale](../../kotlin.text/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.2), JS (1.2), Native (1.2) #### [chunked](../../kotlin.text/chunked) Splits this char sequence into a list of strings each not exceeding the given [size](../../kotlin.text/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](../../kotlin.text/chunked#kotlin.text%24chunked(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunked.R)))/size) and applies the given [transform](../../kotlin.text/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](../../kotlin.text/chunked-sequence) Splits this char sequence into a sequence of strings each not exceeding the given [size](../../kotlin.text/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](../../kotlin.text/chunked-sequence#kotlin.text%24chunkedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.CharSequence,%20kotlin.text.chunkedSequence.R)))/size) and applies the given [transform](../../kotlin.text/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:** JVM (1.0) #### [codePointAt](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [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.ranges.coerceAtLeast.T,%20kotlin.ranges.coerceAtLeast.T)/minimumValue). ``` 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.ranges.coerceAtMost.T,%20kotlin.ranges.coerceAtMost.T)/maximumValue). ``` 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.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.ranges.coerceIn.T,%20kotlin.ranges.coerceIn.T?,%20kotlin.ranges.coerceIn.T?)/maximumValue). ``` 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.0), JS (1.0), Native (1.0) #### [commonPrefixWith](../../kotlin.text/common-prefix-with) Returns the longest string `prefix` such that this char sequence and [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/common-suffix-with) Returns the longest string `suffix` such that this char sequence and [other](../../kotlin.text/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](../../kotlin.text/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.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:** JS (1.1) #### [concat](../../kotlin.text/concat) ``` fun String.concat(str: String): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [contains](../../kotlin.text/contains) Returns `true` if this char sequence contains the specified [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/contains#kotlin.text%24contains(kotlin.CharSequence,%20kotlin.text.Regex)/regex). ``` operator fun CharSequence.contains(regex: Regex): Boolean ``` **Platform and version requirements:** JVM (1.0) #### [contentEquals](../../kotlin.text/content-equals) Returns `true` if this string is equal to the contents of the specified [CharSequence](../-char-sequence/index#kotlin.CharSequence), `false` otherwise. ``` fun String.contentEquals(charSequence: CharSequence): 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. ``` fun String.contentEquals(     stringBuilder: StringBuffer ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.text/count) Returns the length of this char sequence. ``` fun CharSequence.count(): Int ``` Returns the number of characters matching the given [predicate](../../kotlin.text/count#kotlin.text%24count(kotlin.CharSequence,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun CharSequence.count(predicate: (Char) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.4) #### [decapitalize](../../kotlin.text/decapitalize) Returns a copy of this string having its first letter lowercased using the rules of the specified [locale](../../kotlin.text/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.0), Native (1.0) #### [drop](../../kotlin.text/drop) Returns a string with the first [n](../../kotlin.text/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](../../kotlin.text/drop-last) Returns a string with the last [n](../../kotlin.text/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](../../kotlin.text/drop-last-while) Returns a string containing all characters except last characters that satisfy the given [predicate](../../kotlin.text/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](../../kotlin.text/drop-while) Returns a string containing all characters except first characters that satisfy the given [predicate](../../kotlin.text/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) #### [elementAtOrElse](../../kotlin.text/element-at-or-else) Returns a character at the given [index](../../kotlin.text/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](../../kotlin.text/element-at-or-else#kotlin.text%24elementAtOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.text/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](../../kotlin.text/element-at-or-null) Returns a character at the given [index](../../kotlin.text/element-at-or-null#kotlin.text%24elementAtOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.text/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.0), JS (1.0), Native (1.0) #### [endsWith](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [filter](../../kotlin.text/filter) Returns a string containing only those characters from the original string that match the given [predicate](../../kotlin.text/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](../../kotlin.text/filter-indexed) Returns a string containing only those characters from the original string that match the given [predicate](../../kotlin.text/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](../../kotlin.text/filter-indexed-to) Appends all characters matching the given [predicate](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/filter-not) Returns a string containing only those characters from the original string that do not match the given [predicate](../../kotlin.text/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](../../kotlin.text/filter-not-to) Appends all characters not matching the given [predicate](../../kotlin.text/filter-not-to#kotlin.text%24filterNotTo(kotlin.CharSequence,%20kotlin.text.filterNotTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.text/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](../../kotlin.text/filter-to) Appends all characters matching the given [predicate](../../kotlin.text/filter-to#kotlin.text%24filterTo(kotlin.CharSequence,%20kotlin.text.filterTo.C,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.text/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](../../kotlin.text/find) Returns the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/find-any-of) Finds the first occurrence of any of the specified [strings](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/find-last) Returns the last character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/find-last-any-of) Finds the last occurrence of any of the specified [strings](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/first) Returns the first character. ``` fun CharSequence.first(): Char ``` Returns the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/first-not-null-of) Returns the first non-null value produced by [transform](../../kotlin.text/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](../-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](../../kotlin.text/first-not-null-of-or-null) Returns the first non-null value produced by [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/flat-map) Returns a single list of all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/flat-map-indexed) Returns a single list of all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/flat-map-indexed-to) Appends all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/flat-map-to) Appends all elements yielded from results of [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold) Accumulates value starting with [initial](../../kotlin.text/fold#kotlin.text%24fold(kotlin.CharSequence,%20kotlin.text.fold.R,%20kotlin.Function2((kotlin.text.fold.R,%20kotlin.Char,%20)))/initial) value and applying [operation](../../kotlin.text/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](../../kotlin.text/fold-indexed) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold-right) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/fold-right-indexed) Accumulates value starting with [initial](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/for-each) Performs the given [action](../../kotlin.text/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](../../kotlin.text/for-each-indexed) Performs the given [action](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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.0), JS (1.0), Native (1.0) #### [getOrElse](../../kotlin.text/get-or-else) Returns a character at the given [index](../../kotlin.text/get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/index) or the result of calling the [defaultValue](../../kotlin.text/get-or-else#kotlin.text%24getOrElse(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Char)))/defaultValue) function if the [index](../../kotlin.text/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](../../kotlin.text/get-or-null) Returns a character at the given [index](../../kotlin.text/get-or-null#kotlin.text%24getOrNull(kotlin.CharSequence,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.text/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](../../kotlin.text/group-by) Groups characters of the original char sequence by the key returned by the given [keySelector](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/group-by-to) Groups characters of the original char sequence by the key returned by the given [keySelector](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/has-surrogate-pair-at) Returns `true` if this CharSequence has Unicode surrogate pair at the specified [index](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/if-empty) Returns this char sequence if it's not empty or the result of calling [defaultValue](../../kotlin.text/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](../../kotlin.text/index-of) Returns the index within this string of the first occurrence of the specified character, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/index-of#kotlin.text%24indexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/index-of-any) Finds the index of the first occurrence of any of the specified [chars](../../kotlin.text/index-of-any#kotlin.text%24indexOfAny(kotlin.CharSequence,%20kotlin.CharArray,%20kotlin.Int,%20kotlin.Boolean)/chars) in this char sequence, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/index-of-first) Returns index of the first character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/index-of-last) Returns index of the last character matching the given [predicate](../../kotlin.text/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:** JVM (1.0) #### [intern](../../kotlin.text/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) #### [isEmpty](../../kotlin.text/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) #### [isNotBlank](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [iterator](../../kotlin.text/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](../../kotlin.text/last) Returns the last character. ``` fun CharSequence.last(): Char ``` Returns the last character matching the given [predicate](../../kotlin.text/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](../../kotlin.text/last-index-of) Returns the index within this char sequence of the last occurrence of the specified character, starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/last-index-of#kotlin.text%24lastIndexOf(kotlin.CharSequence,%20kotlin.String,%20kotlin.Int,%20kotlin.Boolean)/string), starting from the specified [startIndex](../../kotlin.text/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](../../kotlin.text/last-index-of-any) Finds the index of the last occurrence of any of the specified [chars](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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> ``` **Platform and version requirements:** JVM (1.5) #### [lowercase](../../kotlin.text/lowercase) Returns a copy of this string converted to lower case using the rules of the specified [locale](../../kotlin.text/lowercase#kotlin.text%24lowercase(kotlin.String,%20java.util.Locale)/locale). ``` fun String.lowercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [map](../../kotlin.text/map) Returns a list containing the results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed) Returns a list containing the results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-indexed-not-null-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-indexed-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-not-null) Returns a list containing only the non-null results of applying the given [transform](../../kotlin.text/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](../../kotlin.text/map-not-null-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/map-to) Applies the given [transform](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/match) ``` fun String.match(regex: String): Array<String>? ``` #### [matches](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [maxByOrNull](../../kotlin.text/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](../../kotlin.text/max-of) Returns the largest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/max-of-or-null) Returns the largest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/max-of-with) Returns the largest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-of-with-or-null) Returns the largest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-or-null) Returns the largest character or `null` if there are no characters. ``` fun CharSequence.maxOrNull(): Char? ``` #### [maxWith](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/max-with-or-null) Returns the first character having the largest value according to the provided [comparator](../../kotlin.text/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? ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [minByOrNull](../../kotlin.text/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](../../kotlin.text/min-of) Returns the smallest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/min-of-or-null) Returns the smallest value among all values produced by [selector](../../kotlin.text/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](../../kotlin.text/min-of-with) Returns the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-of-with-or-null) Returns the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-or-null) Returns the smallest character or `null` if there are no characters. ``` fun CharSequence.minOrNull(): Char? ``` #### [minWith](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/min-with-or-null) Returns the first character having the smallest value according to the provided [comparator](../../kotlin.text/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](../../kotlin.text/none) Returns `true` if the char sequence has no characters. ``` fun CharSequence.none(): Boolean ``` Returns `true` if no characters match the given [predicate](../../kotlin.text/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](../../kotlin.text/offset-by-code-points) Returns the index within this string that is offset from the given [index](../../kotlin.text/offset-by-code-points#kotlin.text%24offsetByCodePoints(kotlin.String,%20kotlin.Int,%20kotlin.Int)/index) by [codePointOffset](../../kotlin.text/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](../../kotlin.text/on-each) Performs the given [action](../../kotlin.text/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](../../kotlin.text/on-each-indexed) Performs the given [action](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/pad-end) Pads the string to the specified [length](../../kotlin.text/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](../../kotlin.text/pad-start) Pads the string to the specified [length](../../kotlin.text/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](../../kotlin.text/partition) Splits the original string into pair of strings, where *first* string contains characters for which [predicate](../../kotlin.text/partition#kotlin.text%24partition(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* string contains characters for which [predicate](../../kotlin.text/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) #### [prependIndent](../../kotlin.text/prepend-indent) Prepends [indent](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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) #### [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.0) #### [reader](../../kotlin.io/reader) Creates a new reader for the string. ``` fun String.reader(): StringReader ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reduce](../../kotlin.text/reduce) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-indexed) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-indexed-or-null) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-or-null) Accumulates value starting with the first character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-indexed) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-indexed-or-null) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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](../../kotlin.text/reduce-right-or-null) Accumulates value starting with the last character and applying [operation](../../kotlin.text/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? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun String.refTo(index: Int): CValuesRef<COpaque> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [removePrefix](../../kotlin.text/remove-prefix) If this string starts with the given [prefix](../../kotlin.text/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](../../kotlin.text/remove-range) Removes the part of a string at a given range. ``` fun String.removeRange(     startIndex: Int,     endIndex: Int ): String ``` Removes the part of a string at the given [range](../../kotlin.text/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](../../kotlin.text/remove-suffix) If this string ends with the given [suffix](../../kotlin.text/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](../../kotlin.text/remove-surrounding) Removes from a string both the given [prefix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and [suffix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/suffix) if and only if it starts with the [prefix](../../kotlin.text/remove-surrounding#kotlin.text%24removeSurrounding(kotlin.String,%20kotlin.CharSequence,%20kotlin.CharSequence)/prefix) and ends with the [suffix](../../kotlin.text/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 ``` Removes the given [delimiter](../../kotlin.text/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](../../kotlin.text/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) #### [replace](../../kotlin.text/replace) Returns a new string obtained by replacing each substring of this char sequence that matches the given regular expression with the given [replacement](../../kotlin.text/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](../../kotlin.text/replace#kotlin.text%24replace(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.Function1((kotlin.text.MatchResult,%20kotlin.CharSequence)))/transform) that takes [MatchResult](../../kotlin.text/-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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [replaceAfter](../../kotlin.text/replace-after) Replace part of string after the first occurrence of given delimiter with the [replacement](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/replace-after-last) Replace part of string after the last occurrence of given delimiter with the [replacement](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/replace-before) Replace part of string before the first occurrence of given delimiter with the [replacement](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/replace-before-last) Replace part of string before the last occurrence of given delimiter with the [replacement](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/replace-first) Replaces the first occurrence of the given regular expression [regex](../../kotlin.text/replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/regex) in this char sequence with specified [replacement](../../kotlin.text/replace-first#kotlin.text%24replaceFirst(kotlin.CharSequence,%20kotlin.text.Regex,%20kotlin.String)/replacement) expression. ``` fun CharSequence.replaceFirst(     regex: Regex,     replacement: String ): String ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [replaceFirstChar](../../kotlin.text/replace-first-char) Returns a copy of this string having its first character replaced with the result of the specified [transform](../../kotlin.text/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](../../kotlin.text/replace-indent) Detects a common minimal indent like it does [trimIndent](../../kotlin.text/trim-indent) and replaces it with the specified [newIndent](../../kotlin.text/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](../../kotlin.text/replace-indent-by-margin) Detects indent by [marginPrefix](../../kotlin.text/replace-indent-by-margin#kotlin.text%24replaceIndentByMargin(kotlin.String,%20kotlin.String,%20kotlin.String)/marginPrefix) as it does [trimMargin](../../kotlin.text/trim-margin) and replace it with [newIndent](../../kotlin.text/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](../../kotlin.text/replace-range) Replaces the part of the string at the given range with the [replacement](../../kotlin.text/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 ``` Replace the part of string at the given [range](../../kotlin.text/replace-range#kotlin.text%24replaceRange(kotlin.String,%20kotlin.ranges.IntRange,%20kotlin.CharSequence)/range) with the [replacement](../../kotlin.text/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](../../kotlin.text/reversed) 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](../../kotlin.text/running-fold) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/running-fold-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/running-reduce) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/running-reduce-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/scan) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/scan-indexed) Returns a list containing successive accumulation values generated by applying [operation](../../kotlin.text/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](../../kotlin.text/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:** JVM (1.0), JS (1.0), Native (1.0) #### [single](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/slice) Returns a string containing characters of the original string at the specified range of [indices](../../kotlin.text/slice#kotlin.text%24slice(kotlin.String,%20kotlin.ranges.IntRange)/indices). ``` fun String.slice(indices: IntRange): String ``` Returns a string containing characters of the original string at specified [indices](../../kotlin.text/slice#kotlin.text%24slice(kotlin.String,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun String.slice(indices: Iterable<Int>): String ``` #### [split](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/split-to-sequence) Splits this char sequence to a sequence of strings around occurrences of the specified [delimiters](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [subSequence](../../kotlin.text/sub-sequence) Returns a subsequence of this char sequence. ``` fun String.subSequence(start: Int, end: Int): CharSequence ``` Returns a subsequence of this char sequence specified by the given [range](../../kotlin.text/sub-sequence#kotlin.text%24subSequence(kotlin.CharSequence,%20kotlin.ranges.IntRange)/range) of indices. ``` fun CharSequence.subSequence(range: IntRange): CharSequence ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substring](../../kotlin.text/substring) Returns a substring specified by the given [range](../../kotlin.text/substring#kotlin.text%24substring(kotlin.String,%20kotlin.ranges.IntRange)/range) of indices. ``` fun String.substring(range: IntRange): String ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [substringAfter](../../kotlin.text/substring-after) Returns a substring after the first occurrence of [delimiter](../../kotlin.text/substring-after#kotlin.text%24substringAfter(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](../../kotlin.text/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](../../kotlin.text/substring-after-last) Returns a substring after the last occurrence of [delimiter](../../kotlin.text/substring-after-last#kotlin.text%24substringAfterLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](../../kotlin.text/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](../../kotlin.text/substring-before) Returns a substring before the first occurrence of [delimiter](../../kotlin.text/substring-before#kotlin.text%24substringBefore(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](../../kotlin.text/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](../../kotlin.text/substring-before-last) Returns a substring before the last occurrence of [delimiter](../../kotlin.text/substring-before-last#kotlin.text%24substringBeforeLast(kotlin.String,%20kotlin.Char,%20kotlin.String)/delimiter). If the string does not contain the delimiter, returns [missingDelimiterValue](../../kotlin.text/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](../../kotlin.text/sum-by) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/sum-by-double) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/sum-of) Returns the sum of all values produced by [selector](../../kotlin.text/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](../../kotlin.text/take) Returns a string containing the first [n](../../kotlin.text/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](../../kotlin.text/take-last) Returns a string containing the last [n](../../kotlin.text/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](../../kotlin.text/take-last-while) Returns a string containing last characters that satisfy the given [predicate](../../kotlin.text/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](../../kotlin.text/take-while) Returns a string containing the first characters that satisfy the given [predicate](../../kotlin.text/take-while#kotlin.text%24takeWhile(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate). ``` fun String.takeWhile(predicate: (Char) -> Boolean): String ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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.5), JS (1.5), Native (1.5) #### [toBooleanStrict](../../kotlin.text/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](../../kotlin.text/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) #### [toByteArray](../../kotlin.text/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](../../kotlin.text/to-byte-or-null) Parses the string as a signed [Byte](../-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? ``` **Platform and version requirements:** JVM (1.0) #### [toCharArray](../../kotlin.text/to-char-array) Copies characters from this string into the [destination](../../kotlin.text/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.0), Native (1.0) #### [toCollection](../../kotlin.text/to-collection) Appends all characters to the given [destination](../../kotlin.text/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) #### [toHashSet](../../kotlin.text/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.1), JS (1.1), Native (1.1) #### [toIntOrNull](../../kotlin.text/to-int-or-null) Parses the string as an [Int](../-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](../../kotlin.text/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.1), JS (1.1), Native (1.1) #### [toLongOrNull](../../kotlin.text/to-long-or-null) Parses the string as a [Long](../-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? ``` **Platform and version requirements:** JVM (1.0) #### [toLowerCase](../../kotlin.text/to-lower-case) 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.0), Native (1.0) #### [toMutableList](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/to-regex) Converts the string into a regular expression [Regex](../../kotlin.text/-regex/index#kotlin.text.Regex) with the default options. ``` fun String.toRegex(): Regex ``` Converts the string into a regular expression [Regex](../../kotlin.text/-regex/index#kotlin.text.Regex) with the specified single [option](../../kotlin.text/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](../../kotlin.text/-regex/index#kotlin.text.Regex) with the specified set of [options](../../kotlin.text/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](../../kotlin.text/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.1), JS (1.1), Native (1.1) #### [toShortOrNull](../../kotlin.text/to-short-or-null) Parses the string as a [Short](../-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](../../kotlin.text/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.5), JS (1.5), Native (1.5) #### [toUByte](../../kotlin.text/to-u-byte) Parses the string as a signed [UByte](../-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](../../kotlin.text/to-u-byte-or-null) Parses the string as an [UByte](../-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](../../kotlin.text/to-u-int) Parses the string as an [UInt](../-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](../../kotlin.text/to-u-int-or-null) Parses the string as an [UInt](../-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](../../kotlin.text/to-u-long) Parses the string as a [ULong](../-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](../../kotlin.text/to-u-long-or-null) Parses the string as an [ULong](../-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? ``` **Platform and version requirements:** JVM (1.0) #### [toUpperCase](../../kotlin.text/to-upper-case) 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.5), JS (1.5), Native (1.5) #### [toUShort](../../kotlin.text/to-u-short) Parses the string as a [UShort](../-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](../../kotlin.text/to-u-short-or-null) Parses the string as an [UShort](../-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](../../kotlin.text/trim) Returns a string having leading and trailing characters matching the [predicate](../../kotlin.text/trim#kotlin.text%24trim(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trim(predicate: (Char) -> Boolean): String ``` Returns a string having leading and trailing characters from the [chars](../../kotlin.text/trim#kotlin.text%24trim(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trim(vararg chars: Char): String ``` 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](../../kotlin.text/trim-end) Returns a string having trailing characters matching the [predicate](../../kotlin.text/trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trimEnd(predicate: (Char) -> Boolean): String ``` Returns a string having trailing characters from the [chars](../../kotlin.text/trim-end#kotlin.text%24trimEnd(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trimEnd(vararg chars: Char): String ``` 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](../../kotlin.text/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](../../kotlin.text/trim-margin) Trims leading whitespace characters followed by [marginPrefix](../../kotlin.text/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](../../kotlin.text/trim-start) Returns a string having leading characters matching the [predicate](../../kotlin.text/trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.Function1((kotlin.Char,%20kotlin.Boolean)))/predicate) removed. ``` fun String.trimStart(predicate: (Char) -> Boolean): String ``` Returns a string having leading characters from the [chars](../../kotlin.text/trim-start#kotlin.text%24trimStart(kotlin.String,%20kotlin.CharArray)/chars) array removed. ``` fun String.trimStart(vararg chars: Char): String ``` Returns a string having leading whitespace removed. ``` fun String.trimStart(): String ``` **Platform and version requirements:** JVM (1.5) #### [uppercase](../../kotlin.text/uppercase) Returns a copy of this string converted to upper case using the rules of the specified [locale](../../kotlin.text/uppercase#kotlin.text%24uppercase(kotlin.String,%20java.util.Locale)/locale). ``` fun String.uppercase(locale: Locale): String ``` **Platform and version requirements:** JVM (1.2), JS (1.2), Native (1.2) #### [windowed](../../kotlin.text/windowed) Returns a list of snapshots of the window of the given [size](../../kotlin.text/windowed#kotlin.text%24windowed(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/windowed-sequence) Returns a sequence of snapshots of the window of the given [size](../../kotlin.text/windowed-sequence#kotlin.text%24windowedSequence(kotlin.CharSequence,%20kotlin.Int,%20kotlin.Int,%20kotlin.Boolean)/size) sliding along this char sequence with the given [step](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/zip) Returns a list of pairs built from the characters of `this` and the [other](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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 Extension Functions ------------------------------------ **Platform and version requirements:** JVM (1.0) #### [format](../../kotlin.text/format) Uses the provided [format](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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](../../kotlin.text/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 compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / [compareTo](compare-to) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun compareTo(other: String): Int ``` Compares this object with the specified object for order. Returns zero if this object is equal to the specified [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other) object, a negative number if it's less than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other), or a positive number if it's greater than [other](../-comparable/compare-to#kotlin.Comparable%24compareTo(kotlin.Comparable.T)/other). kotlin length length ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / <length> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val length: Int ``` Returns the length of this character sequence. kotlin hashCode hashCode ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](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 toString toString ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](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 <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are implemented as instances of this class. kotlin subSequence subSequence =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / [subSequence](sub-sequence) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun subSequence(startIndex: Int, endIndex: Int): CharSequence ``` Returns a new character sequence that is a subsequence of this character sequence, starting at the specified [startIndex](../-char-sequence/sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/startIndex) and ending right before the specified [endIndex](../-char-sequence/sub-sequence#kotlin.CharSequence%24subSequence(kotlin.Int,%20kotlin.Int)/endIndex). Parameters ---------- `startIndex` - the start index (inclusive). `endIndex` - the end index (exclusive). kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / <equals> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` 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. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun plus(other: Any?): String ``` Returns a string obtained by concatenating this string with the string representation of the given [other](plus#kotlin.String%24plus(kotlin.Any?)/other) object. kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [String](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun get(index: Int): Char ``` ##### For Common, JVM, JS Returns the character of this string at the specified [index](get#kotlin.String%24get(kotlin.Int)/index). If the [index](get#kotlin.String%24get(kotlin.Int)/index) is out of bounds of this string, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException) except in Kotlin/JS where the behavior is unspecified. ##### For Native Returns the character of this string at the specified [index](get#kotlin.String%24get(kotlin.Int)/index). If the [index](get#kotlin.String%24get(kotlin.Int)/index) is out of bounds of this string, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin ContextFunctionTypeParams ContextFunctionTypeParams ========================= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ContextFunctionTypeParams](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` @Target([AnnotationTarget.TYPE]) annotation class ContextFunctionTypeParams ``` Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) ``` <init>(count: Int) ``` Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <count> ``` val count: Int ``` 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 count count ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ContextFunctionTypeParams](index) / <count> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` val count: Int ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ContextFunctionTypeParams](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(count: Int) ``` kotlin NullPointerException NullPointerException ==================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NullPointerException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NullPointerException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NullPointerException = NullPointerException ``` 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> ``` Inheritors ---------- **Platform and version requirements:** JVM (1.0) #### [KotlinNullPointerException](../-kotlin-null-pointer-exception/index) ``` open class KotlinNullPointerException : NullPointerException ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NullPointerException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin ByteArray ByteArray ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class ByteArray ``` ##### For Common, JVM, JS An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`. ##### For Native An array of bytes. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Byte) ``` Creates a new array of the specified [size](size#kotlin.ByteArray%24size), with all elements initialized to zero. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.ByteArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): Byte ``` **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(): ByteIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/index) to the given [value](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Byte) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val ByteArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val ByteArray.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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.all(predicate: (Byte) -> 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 ByteArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.any(predicate: (Byte) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun ByteArray.asIterable(): Iterable<Byte> ``` **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 array returning its elements when being iterated. ``` fun ByteArray.asSequence(): Sequence<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> ByteArray.associate(     transform: (Byte) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> ByteArray.associateBy(     keySelector: (Byte) -> K ): Map<K, Byte> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> ByteArray.associateBy(     keySelector: (Byte) -> K,     valueTransform: (Byte) -> 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.ByteArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Byte>> ByteArray.associateByTo(     destination: M,     keySelector: (Byte) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.ByteArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.ByteArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateByTo(     destination: M,     keySelector: (Byte) -> K,     valueTransform: (Byte) -> 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.ByteArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> ByteArray.associateTo(     destination: M,     transform: (Byte) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> ByteArray.associateWith(     valueSelector: (Byte) -> V ): Map<Byte, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.ByteArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Byte, in V>> ByteArray.associateWithTo(     destination: M,     valueSelector: (Byte) -> V ): M ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [asUByteArray](../../kotlin.collections/as-u-byte-array) Returns an array of type [UByteArray](../-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.0), JS (1.0), Native (1.0) #### [average](../../kotlin.collections/average) Returns an average value of elements in the array. ``` fun ByteArray.average(): Double ``` **Platform and version requirements:** JVM (1.0) #### [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.ByteArray,%20kotlin.Byte,%20kotlin.Int,%20kotlin.Int)/element) using the binary search algorithm. The array is expected to be sorted, otherwise the result is undefined. ``` fun ByteArray.binarySearch(     element: Byte,     fromIndex: Int = 0,     toIndex: Int = size ): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun ByteArray.component1(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun ByteArray.component2(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun ByteArray.component3(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun ByteArray.component4(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun ByteArray.component5(): Byte ``` **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.ByteArray,%20kotlin.Byte)/element) is found in the array. ``` operator fun ByteArray.contains(element: Byte): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun ByteArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.count(predicate: (Byte) -> 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 array. ``` fun ByteArray.distinct(): List<Byte> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> ByteArray.distinctBy(     selector: (Byte) -> K ): List<Byte> ``` **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.ByteArray,%20kotlin.Int)/n) elements. ``` fun ByteArray.drop(n: Int): List<Byte> ``` **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.ByteArray,%20kotlin.Int)/n) elements. ``` fun ByteArray.dropLast(n: Int): List<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.dropLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.dropWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/index) is out of bounds of this array. ``` fun ByteArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ByteArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.ByteArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ByteArray.elementAtOrNull(index: Int): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.filter(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.filterIndexed(     predicate: (index: Int, Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.ByteArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Byte>> ByteArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Byte) -> Boolean ): 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.filterNot(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.ByteArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Byte>> ByteArray.filterNotTo(     destination: C,     predicate: (Byte) -> 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.ByteArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.ByteArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/destination). ``` fun <C : MutableCollection<in Byte>> ByteArray.filterTo(     destination: C,     predicate: (Byte) -> 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ByteArray.find(predicate: (Byte) -> Boolean): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ByteArray.findLast(predicate: (Byte) -> Boolean): Byte? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun ByteArray.first(): Byte ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.first(predicate: (Byte) -> Boolean): Byte ``` **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 ByteArray.firstOrNull(): Byte? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or `null` if element was not found. ``` fun ByteArray.firstOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> ByteArray.flatMap(     transform: (Byte) -> Iterable<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.ByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> ByteArray.flatMapIndexed(     transform: (index: Int, Byte) -> Iterable<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.ByteArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%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.ByteArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ByteArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> Iterable<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.ByteArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> ByteArray.flatMapTo(     destination: C,     transform: (Byte) -> Iterable<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.ByteArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Byte,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.ByteArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Byte,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> ByteArray.fold(     initial: R,     operation: (acc: R, Byte) -> 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.ByteArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Byte,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.ByteArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Byte,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> ByteArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> 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.ByteArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Byte,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.ByteArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Byte,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> ByteArray.foldRight(     initial: R,     operation: (Byte, 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.ByteArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.ByteArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%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> ByteArray.foldRightIndexed(     initial: R,     operation: (index: Int, Byte, 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Unit)))/action) on each element. ``` fun ByteArray.forEach(action: (Byte) -> 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.ByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun ByteArray.forEachIndexed(     action: (index: Int, Byte) -> Unit) ``` **Platform and version requirements:** Native (1.3) #### [getCharAt](../../kotlin.native/get-char-at) Gets [Char](../-char/index#kotlin.Char) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-char-at#kotlin.native%24getCharAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getCharAt(index: Int): Char ``` **Platform and version requirements:** Native (1.3) #### [getDoubleAt](../../kotlin.native/get-double-at) Gets [Double](../-double/index#kotlin.Double) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-double-at#kotlin.native%24getDoubleAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getDoubleAt(index: Int): Double ``` **Platform and version requirements:** Native (1.3) #### [getFloatAt](../../kotlin.native/get-float-at) Gets [Float](../-float/index#kotlin.Float) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-float-at#kotlin.native%24getFloatAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getFloatAt(index: Int): Float ``` **Platform and version requirements:** Native (1.3) #### [getIntAt](../../kotlin.native/get-int-at) Gets [Int](../-int/index#kotlin.Int) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-int-at#kotlin.native%24getIntAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getIntAt(index: Int): Int ``` **Platform and version requirements:** Native (1.3) #### [getLongAt](../../kotlin.native/get-long-at) Gets [Long](../-long/index#kotlin.Long) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-long-at#kotlin.native%24getLongAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getLongAt(index: Int): Long ``` **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.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Byte)))/index) is out of bounds of this array. ``` fun ByteArray.getOrElse(     index: Int,     defaultValue: (Int) -> Byte ): Byte ``` **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.ByteArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.ByteArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun ByteArray.getOrNull(index: Int): Byte? ``` **Platform and version requirements:** Native (1.3) #### [getShortAt](../../kotlin.native/get-short-at) Gets [Short](../-short/index#kotlin.Short) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-short-at#kotlin.native%24getShortAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getShortAt(index: Int): Short ``` **Platform and version requirements:** Native (1.3) #### [getUByteAt](../../kotlin.native/get-u-byte-at) Gets UByte out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-u-byte-at#kotlin.native%24getUByteAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUByteAt(index: Int): UByte ``` **Platform and version requirements:** Native (1.3) #### [getUIntAt](../../kotlin.native/get-u-int-at) Gets UInt out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-u-int-at#kotlin.native%24getUIntAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUIntAt(index: Int): UInt ``` **Platform and version requirements:** Native (1.3) #### [getULongAt](../../kotlin.native/get-u-long-at) Gets ULong out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-u-long-at#kotlin.native%24getULongAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getULongAt(index: Int): ULong ``` **Platform and version requirements:** Native (1.3) #### [getUShortAt](../../kotlin.native/get-u-short-at) Gets UShort out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/get-u-short-at#kotlin.native%24getUShortAt(kotlin.ByteArray,%20kotlin.Int)/index) ``` fun ByteArray.getUShortAt(index: Int): UShort ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%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> ByteArray.groupBy(     keySelector: (Byte) -> K ): Map<K, List<Byte>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Byte,%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> ByteArray.groupBy(     keySelector: (Byte) -> K,     valueTransform: (Byte) -> 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.ByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Byte>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.ByteArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Byte,%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>>> ByteArray.groupByTo(     destination: M,     keySelector: (Byte) -> K,     valueTransform: (Byte) -> V ): M ``` **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.ByteArray,%20kotlin.Byte)/element), or -1 if the array does not contain element. ``` fun ByteArray.indexOf(element: Byte): 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ByteArray.indexOfFirst(predicate: (Byte) -> 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or -1 if the array does not contain such element. ``` fun ByteArray.indexOfLast(predicate: (Byte) -> Boolean): Int ``` **Platform and version requirements:** JVM (1.0) #### [inputStream](../../kotlin.io/input-stream) Creates an input stream for reading data from this byte array. ``` fun ByteArray.inputStream(): ByteArrayInputStream ``` Creates an input stream for reading data from the specified portion of this byte array. ``` fun ByteArray.inputStream(     offset: Int,     length: Int ): ByteArrayInputStream ``` **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 array and the specified collection. ``` infix fun ByteArray.intersect(     other: Iterable<Byte> ): Set<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun ByteArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun ByteArray.isNotEmpty(): 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.ByteArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.ByteArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.ByteArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> ByteArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> 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.ByteArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.ByteArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.ByteArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Byte,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun ByteArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Byte) -> 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 ByteArray.last(): Byte ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.last(predicate: (Byte) -> Boolean): Byte ``` **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.ByteArray,%20kotlin.Byte)/element), or -1 if the array does not contain element. ``` fun ByteArray.lastIndexOf(element: Byte): 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 ByteArray.lastOrNull(): Byte? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or `null` if no such element was found. ``` fun ByteArray.lastOrNull(predicate: (Byte) -> Boolean): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> ByteArray.map(transform: (Byte) -> 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.ByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> ByteArray.mapIndexed(     transform: (index: Int, Byte) -> R ): List<R> ``` **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.ByteArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%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.ByteArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ByteArray.mapIndexedTo(     destination: C,     transform: (index: Int, Byte) -> 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.ByteArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Byte,%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.ByteArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> ByteArray.mapTo(     destination: C,     transform: (Byte) -> 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>> ByteArray.maxByOrNull(     selector: (Byte) -> R ): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Byte) -> 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Byte) -> 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.ByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.ByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ByteArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> 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.ByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.ByteArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ByteArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> 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 ByteArray.maxOrNull(): Byte? ``` #### [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.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator). ``` fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun ByteArray.maxWith(comparator: Comparator<in Byte>): Byte? ``` **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.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator) or `null` if there are no elements. ``` fun ByteArray.maxWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` **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>> ByteArray.minByOrNull(     selector: (Byte) -> R ): Byte? ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Byte) -> 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Byte) -> 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.ByteArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.ByteArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> ByteArray.minOfWith(     comparator: Comparator<in R>,     selector: (Byte) -> 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.ByteArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.ByteArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> ByteArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Byte) -> 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 ByteArray.minOrNull(): Byte? ``` #### [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.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator). ``` fun ByteArray.minWith(comparator: Comparator<in Byte>): Byte ``` **Platform and version requirements:** JVM (1.0) ``` fun ByteArray.minWith(comparator: Comparator<in Byte>): Byte? ``` **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.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator) or `null` if there are no elements. ``` fun ByteArray.minWithOrNull(     comparator: Comparator<in Byte> ): Byte? ``` **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 ByteArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.none(predicate: (Byte) -> Boolean): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun ByteArray.onEach(action: (Byte) -> Unit): ByteArray ``` **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.ByteArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Byte,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun ByteArray.onEachIndexed(     action: (index: Int, Byte) -> Unit ): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate) yielded `false`. ``` fun ByteArray.partition(     predicate: (Byte) -> Boolean ): Pair<List<Byte>, List<Byte>> ``` **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 ByteArray.random(): Byte ``` Returns a random element from this array using the specified source of randomness. ``` fun ByteArray.random(random: Random): Byte ``` **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 ByteArray.randomOrNull(): Byte? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun ByteArray.randomOrNull(random: Random): Byte? ``` **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.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ByteArray.reduce(     operation: (acc: Byte, Byte) -> Byte ): Byte ``` **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.ByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ByteArray.reduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte ``` **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.ByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun ByteArray.reduceIndexedOrNull(     operation: (index: Int, acc: Byte, Byte) -> Byte ): Byte? ``` **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.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun ByteArray.reduceOrNull(     operation: (acc: Byte, Byte) -> Byte ): Byte? ``` **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.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ByteArray.reduceRight(     operation: (Byte, acc: Byte) -> Byte ): Byte ``` **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.ByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ByteArray.reduceRightIndexed(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte ``` **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.ByteArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Byte,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun ByteArray.reduceRightIndexedOrNull(     operation: (index: Int, Byte, acc: Byte) -> Byte ): Byte? ``` **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.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun ByteArray.reduceRightOrNull(     operation: (Byte, acc: Byte) -> Byte ): Byte? ``` **Platform and version requirements:** Native (1.3) #### [refTo](../../kotlinx.cinterop/ref-to) ``` fun ByteArray.refTo(index: Int): CValuesRef<ByteVar> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun ByteArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun ByteArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 ByteArray.reversed(): List<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun ByteArray.reversedArray(): ByteArray ``` **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.ByteArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Byte,%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.ByteArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Byte,%20)))/initial) value. ``` fun <R> ByteArray.runningFold(     initial: R,     operation: (acc: R, Byte) -> 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.ByteArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Byte,%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.ByteArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Byte,%20)))/initial) value. ``` fun <R> ByteArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> 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.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. ``` fun ByteArray.runningReduce(     operation: (acc: Byte, Byte) -> Byte ): List<Byte> ``` **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.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. ``` fun ByteArray.runningReduceIndexed(     operation: (index: Int, acc: Byte, Byte) -> Byte ): List<Byte> ``` **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.ByteArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Byte,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.ByteArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Byte,%20)))/initial) value. ``` fun <R> ByteArray.scan(     initial: R,     operation: (acc: R, Byte) -> 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.ByteArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Byte,%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.ByteArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Byte,%20)))/initial) value. ``` fun <R> ByteArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Byte) -> R ): List<R> ``` **Platform and version requirements:** Native (1.3) #### [setCharAt](../../kotlin.native/set-char-at) Sets [Char](../-char/index#kotlin.Char) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-char-at#kotlin.native%24setCharAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Char)/index) ``` fun ByteArray.setCharAt(index: Int, value: Char) ``` **Platform and version requirements:** Native (1.3) #### [setDoubleAt](../../kotlin.native/set-double-at) Sets [Double](../-double/index#kotlin.Double) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-double-at#kotlin.native%24setDoubleAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Double)/index) ``` fun ByteArray.setDoubleAt(index: Int, value: Double) ``` **Platform and version requirements:** Native (1.3) #### [setFloatAt](../../kotlin.native/set-float-at) Sets [Float](../-float/index#kotlin.Float) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-float-at#kotlin.native%24setFloatAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Float)/index) ``` fun ByteArray.setFloatAt(index: Int, value: Float) ``` **Platform and version requirements:** Native (1.3) #### [setIntAt](../../kotlin.native/set-int-at) Sets [Int](../-int/index#kotlin.Int) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-int-at#kotlin.native%24setIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int)/index) ``` fun ByteArray.setIntAt(index: Int, value: Int) ``` **Platform and version requirements:** Native (1.3) #### [setLongAt](../../kotlin.native/set-long-at) Sets [Long](../-long/index#kotlin.Long) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-long-at#kotlin.native%24setLongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Long)/index) ``` fun ByteArray.setLongAt(index: Int, value: Long) ``` **Platform and version requirements:** Native (1.3) #### [setShortAt](../../kotlin.native/set-short-at) Sets [Short](../-short/index#kotlin.Short) out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-short-at#kotlin.native%24setShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Short)/index) ``` fun ByteArray.setShortAt(index: Int, value: Short) ``` **Platform and version requirements:** Native (1.3) #### [setUByteAt](../../kotlin.native/set-u-byte-at) Sets UByte out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-u-byte-at#kotlin.native%24setUByteAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UByte)/index) ``` fun ByteArray.setUByteAt(index: Int, value: UByte) ``` **Platform and version requirements:** Native (1.3) #### [setUIntAt](../../kotlin.native/set-u-int-at) Sets UInt out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-u-int-at#kotlin.native%24setUIntAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UInt)/index) ``` fun ByteArray.setUIntAt(index: Int, value: UInt) ``` **Platform and version requirements:** Native (1.3) #### [setULongAt](../../kotlin.native/set-u-long-at) Sets ULong out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-u-long-at#kotlin.native%24setULongAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.ULong)/index) ``` fun ByteArray.setULongAt(index: Int, value: ULong) ``` **Platform and version requirements:** Native (1.3) #### [setUShortAt](../../kotlin.native/set-u-short-at) Sets UShort out of the [ByteArray](index#kotlin.ByteArray) byte buffer at specified index [index](../../kotlin.native/set-u-short-at#kotlin.native%24setUShortAt(kotlin.ByteArray,%20kotlin.Int,%20kotlin.UShort)/index) ``` fun ByteArray.setUShortAt(index: Int, value: UShort) ``` **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 ByteArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.ByteArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun ByteArray.shuffle(random: Random) ``` **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 ByteArray.single(): Byte ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or throws exception if there is no or more than one matching element. ``` fun ByteArray.single(predicate: (Byte) -> Boolean): Byte ``` **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 ByteArray.singleOrNull(): Byte? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate), or `null` if element was not found or more than one element was found. ``` fun ByteArray.singleOrNull(     predicate: (Byte) -> Boolean ): Byte? ``` **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.ByteArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ByteArray.slice(indices: IntRange): List<Byte> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.ByteArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun ByteArray.slice(indices: Iterable<Int>): List<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ByteArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun ByteArray.sliceArray(indices: Collection<Int>): ByteArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.ByteArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun ByteArray.sliceArray(indices: IntRange): ByteArray ``` **Platform and version requirements:** JS (1.1) #### [sort](../../kotlin.collections/sort) Sorts the array in-place according to the order specified by the given [comparison](../../kotlin.collections/sort#kotlin.collections%24sort(kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.Int)))/comparison) function. ``` fun ByteArray.sort(comparison: (a: Byte, b: Byte) -> Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortDescending](../../kotlin.collections/sort-descending) Sorts elements in the array in-place descending according to their natural sort order. ``` fun ByteArray.sortDescending() ``` Sorts elements of the array in the specified range in-place. The elements are sorted descending according to their natural sort order. ``` fun ByteArray.sortDescending(fromIndex: Int, toIndex: Int) ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sorted](../../kotlin.collections/sorted) Returns a list of all elements sorted according to their natural sort order. ``` fun ByteArray.sorted(): List<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArray](../../kotlin.collections/sorted-array) Returns an array with all elements of this array sorted according to their natural sort order. ``` fun ByteArray.sortedArray(): ByteArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedArrayDescending](../../kotlin.collections/sorted-array-descending) Returns an array with all elements of this array sorted descending according to their natural sort order. ``` fun ByteArray.sortedArrayDescending(): ByteArray ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> ByteArray.sortedBy(     selector: (Byte) -> R? ): List<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> ByteArray.sortedByDescending(     selector: (Byte) -> R? ): List<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sortedDescending](../../kotlin.collections/sorted-descending) Returns a list of all elements sorted descending according to their natural sort order. ``` fun ByteArray.sortedDescending(): List<Byte> ``` **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.ByteArray,%20kotlin.Comparator((kotlin.Byte)))/comparator). ``` fun ByteArray.sortedWith(     comparator: Comparator<in Byte> ): List<Byte> ``` **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 array and not contained by the specified collection. ``` infix fun ByteArray.subtract(     other: Iterable<Byte> ): Set<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sum](../../kotlin.collections/sum) Returns the sum of all elements in the array. ``` fun ByteArray.sum(): Int ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun ByteArray.sumBy(selector: (Byte) -> 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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun ByteArray.sumByDouble(selector: (Byte) -> Double): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.ByteArray,%20kotlin.Function1((kotlin.Byte,%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 ByteArray.sumOf(selector: (Byte) -> Double): Double ``` **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 ByteArray.sumOf(selector: (Byte) -> Long): Long ``` **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 ByteArray.sumOf(selector: (Byte) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun ByteArray.sumOf(     selector: (Byte) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun ByteArray.sumOf(     selector: (Byte) -> BigInteger ): BigInteger ``` **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.ByteArray,%20kotlin.Int)/n) elements. ``` fun ByteArray.take(n: Int): List<Byte> ``` **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.ByteArray,%20kotlin.Int)/n) elements. ``` fun ByteArray.takeLast(n: Int): List<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.takeLastWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.Function1((kotlin.Byte,%20kotlin.Boolean)))/predicate). ``` fun ByteArray.takeWhile(     predicate: (Byte) -> Boolean ): List<Byte> ``` **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.ByteArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Byte>> ByteArray.toCollection(     destination: C ): C ``` **Platform and version requirements:** Native (1.3) #### [toCValues](../../kotlinx.cinterop/to-c-values) ``` fun ByteArray.toCValues(): CValues<ByteVar> ``` **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 ByteArray.toHashSet(): HashSet<Byte> ``` **Platform and version requirements:** Native (1.3) #### [toKString](../../kotlinx.cinterop/to-k-string) Decodes a string from the bytes in UTF-8 encoding in this array. Bytes following the first occurrence of `0` byte, if it occurs, are not decoded. ``` fun ByteArray.toKString(): String ``` Decodes a string from the bytes in UTF-8 encoding in this array or its subrange. Bytes following the first occurrence of `0` byte, if it occurs, are not decoded. ``` fun ByteArray.toKString(     startIndex: Int = 0,     endIndex: Int = this.size,     throwOnInvalidSequence: Boolean = false ): String ``` **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 ByteArray.toList(): List<Byte> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun ByteArray.toMutableList(): MutableList<Byte> ``` **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 array. ``` fun ByteArray.toMutableSet(): MutableSet<Byte> ``` **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 ByteArray.toSet(): Set<Byte> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun ByteArray.toSortedSet(): SortedSet<Byte> ``` **Platform and version requirements:** JVM (1.0) #### [toString](../../kotlin.collections/to-string) Converts the contents of this byte array to a string using the specified [charset](../../kotlin.collections/to-string#kotlin.collections%24toString(kotlin.ByteArray,%20java.nio.charset.Charset)/charset). ``` fun ByteArray.toString(charset: Charset): String ``` **Platform and version requirements:** JVM (1.3), JS (1.3), Native (1.3) #### [toUByteArray](../../kotlin.collections/to-u-byte-array) Returns an array of type [UByteArray](../-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 ``` **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 ByteArray.union(other: Iterable<Byte>): Set<Byte> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun ByteArray.withIndex(): Iterable<IndexedValue<Byte>> ``` **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.ByteArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Byte, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Byte,%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.ByteArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Byte,%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> ByteArray.zip(     other: Array<out R>,     transform: (a: Byte, 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.ByteArray,%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> ByteArray.zip(     other: Iterable<R> ): List<Pair<Byte, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.ByteArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Byte,%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.ByteArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Byte,%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> ByteArray.zip(     other: Iterable<R>,     transform: (a: Byte, 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.ByteArray,%20kotlin.ByteArray,%20kotlin.Function2((kotlin.Byte,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/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> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): ByteIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Byte) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.ByteArray%24size), with all elements initialized to zero. **Constructor** Creates a new array of the specified [size](size#kotlin.ByteArray%24size), with all elements initialized to zero. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Byte) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/index) to the given [value](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/value). This method can be called using the index operator. If the [index](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/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. ##### For Native Sets the element at the given [index](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/index) to the given [value](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/value). This method can be called using the index operator. If the [index](set#kotlin.ByteArray%24set(kotlin.Int,%20kotlin.Byte)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [ByteArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Byte ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.ByteArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.ByteArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.ByteArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.ByteArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin size size ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) / <size> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` val size: Int ``` Returns the number of elements in the array. kotlin BooleanArray BooleanArray ============ [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class BooleanArray ``` An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`. Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) Creates a new array of the specified size, where each element is calculated by calling the specified init function. ``` <init>(size: Int, init: (Int) -> Boolean) ``` Creates a new array of the specified [size](size#kotlin.BooleanArray%24size), with all elements initialized to `false`. ``` <init>(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) #### <get> Returns the array element at the given [index](get#kotlin.BooleanArray%24get(kotlin.Int)/index). This method can be called using the index operator. ``` operator fun get(index: Int): 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(): BooleanIterator ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <set> Sets the element at the given [index](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/index) to the given [value](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/value). This method can be called using the index operator. ``` operator fun set(index: Int, value: Boolean) ``` Extension Properties -------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [indices](../../kotlin.collections/indices) Returns the range of valid indices for the array. ``` val BooleanArray.indices: IntRange ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [lastIndex](../../kotlin.collections/last-index) Returns the last valid index for the array. ``` val BooleanArray.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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.all(     predicate: (Boolean) -> 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 BooleanArray.any(): Boolean ``` Returns `true` if at least one element matches the given [predicate](../../kotlin.collections/any#kotlin.collections%24any(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.any(     predicate: (Boolean) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [asIterable](../../kotlin.collections/as-iterable) Creates an [Iterable](../../kotlin.collections/-iterable/index#kotlin.collections.Iterable) instance that wraps the original array returning its elements when being iterated. ``` fun BooleanArray.asIterable(): Iterable<Boolean> ``` **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 array returning its elements when being iterated. ``` fun BooleanArray.asSequence(): Sequence<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Pair((kotlin.collections.associate.K,%20kotlin.collections.associate.V)))))/transform) function applied to elements of the given array. ``` fun <K, V> BooleanArray.associate(     transform: (Boolean) -> 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 array indexed by the key returned from [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateBy.K)))/keySelector) function applied to each element. ``` fun <K> BooleanArray.associateBy(     keySelector: (Boolean) -> K ): Map<K, Boolean> ``` Returns a [Map](../../kotlin.collections/-map/index#kotlin.collections.Map) containing the values provided by [valueTransform](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateBy.V)))/valueTransform) and indexed by [keySelector](../../kotlin.collections/associate-by#kotlin.collections%24associateBy(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateBy.K)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateBy.V)))/keySelector) functions applied to elements of the given array. ``` fun <K, V> BooleanArray.associateBy(     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> 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.BooleanArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.K)))/keySelector) function applied to each element of the given array and value is the element itself. ``` fun <K, M : MutableMap<in K, in Boolean>> BooleanArray.associateByTo(     destination: M,     keySelector: (Boolean) -> K ): M ``` Populates and returns the [destination](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.BooleanArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.V)))/keySelector) function and and value is provided by the [valueTransform](../../kotlin.collections/associate-by-to#kotlin.collections%24associateByTo(kotlin.BooleanArray,%20kotlin.collections.associateByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.K)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateByTo.V)))/valueTransform) function applied to elements of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateByTo(     destination: M,     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> 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.BooleanArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.associateTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Pair((kotlin.collections.associateTo.K,%20kotlin.collections.associateTo.V)))))/transform) function applied to each element of the given array. ``` fun <K, V, M : MutableMap<in K, in V>> BooleanArray.associateTo(     destination: M,     transform: (Boolean) -> Pair<K, V> ): M ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateWith.V)))/valueSelector) function applied to each element. ``` fun <V> BooleanArray.associateWith(     valueSelector: (Boolean) -> V ): Map<Boolean, V> ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [associateWithTo](../../kotlin.collections/associate-with-to) Populates and returns the [destination](../../kotlin.collections/associate-with-to#kotlin.collections%24associateWithTo(kotlin.BooleanArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.associateWithTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.associateWithTo.V)))/valueSelector) function applied to that key. ``` fun <V, M : MutableMap<in Boolean, in V>> BooleanArray.associateWithTo(     destination: M,     valueSelector: (Boolean) -> V ): M ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component1](../../kotlin.collections/component1) Returns 1st *element* from the array. ``` operator fun BooleanArray.component1(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component2](../../kotlin.collections/component2) Returns 2nd *element* from the array. ``` operator fun BooleanArray.component2(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component3](../../kotlin.collections/component3) Returns 3rd *element* from the array. ``` operator fun BooleanArray.component3(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component4](../../kotlin.collections/component4) Returns 4th *element* from the array. ``` operator fun BooleanArray.component4(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [component5](../../kotlin.collections/component5) Returns 5th *element* from the array. ``` operator fun BooleanArray.component5(): Boolean ``` **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.BooleanArray,%20kotlin.Boolean)/element) is found in the array. ``` operator fun BooleanArray.contains(element: Boolean): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [count](../../kotlin.collections/count) Returns the number of elements in this array. ``` fun BooleanArray.count(): Int ``` Returns the number of elements matching the given [predicate](../../kotlin.collections/count#kotlin.collections%24count(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.count(predicate: (Boolean) -> 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 array. ``` fun BooleanArray.distinct(): List<Boolean> ``` **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 array having distinct keys returned by the given [selector](../../kotlin.collections/distinct-by#kotlin.collections%24distinctBy(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.distinctBy.K)))/selector) function. ``` fun <K> BooleanArray.distinctBy(     selector: (Boolean) -> K ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Int)/n) elements. ``` fun BooleanArray.drop(n: Int): List<Boolean> ``` **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.BooleanArray,%20kotlin.Int)/n) elements. ``` fun BooleanArray.dropLast(n: Int): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.dropLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.dropWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/index) or the result of calling the [defaultValue](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/defaultValue) function if the [index](../../kotlin.collections/element-at-or-else#kotlin.collections%24elementAtOrElse(kotlin.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/index) is out of bounds of this array. ``` fun BooleanArray.elementAtOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [elementAtOrNull](../../kotlin.collections/element-at-or-null) Returns an element at the given [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.BooleanArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/element-at-or-null#kotlin.collections%24elementAtOrNull(kotlin.BooleanArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun BooleanArray.elementAtOrNull(index: Int): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.filter(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.filterIndexed(     predicate: (index: Int, Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20)))/predicate) to the given [destination](../../kotlin.collections/filter-indexed-to#kotlin.collections%24filterIndexedTo(kotlin.BooleanArray,%20kotlin.collections.filterIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20)))/destination). ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterIndexedTo(     destination: C,     predicate: (index: Int, Boolean) -> Boolean ): 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.filterNot(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate) to the given [destination](../../kotlin.collections/filter-not-to#kotlin.collections%24filterNotTo(kotlin.BooleanArray,%20kotlin.collections.filterNotTo.C,%20kotlin.Function1((kotlin.Boolean,%20)))/destination). ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterNotTo(     destination: C,     predicate: (Boolean) -> 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.BooleanArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate) to the given [destination](../../kotlin.collections/filter-to#kotlin.collections%24filterTo(kotlin.BooleanArray,%20kotlin.collections.filterTo.C,%20kotlin.Function1((kotlin.Boolean,%20)))/destination). ``` fun <C : MutableCollection<in Boolean>> BooleanArray.filterTo(     destination: C,     predicate: (Boolean) -> 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or `null` if no such element was found. ``` fun BooleanArray.find(     predicate: (Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or `null` if no such element was found. ``` fun BooleanArray.findLast(     predicate: (Boolean) -> Boolean ): Boolean? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [first](../../kotlin.collections/first) Returns the first element. ``` fun BooleanArray.first(): Boolean ``` Returns the first element matching the given [predicate](../../kotlin.collections/first#kotlin.collections%24first(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.first(     predicate: (Boolean) -> Boolean ): Boolean ``` **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 BooleanArray.firstOrNull(): Boolean? ``` Returns the first element matching the given [predicate](../../kotlin.collections/first-or-null#kotlin.collections%24firstOrNull(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or `null` if element was not found. ``` fun BooleanArray.firstOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.Iterable((kotlin.collections.flatMap.R)))))/transform) function being invoked on each element of original array. ``` fun <R> BooleanArray.flatMap(     transform: (Boolean) -> Iterable<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.BooleanArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexed.R)))))/transform) function being invoked on each element and its index in the original array. ``` fun <R> BooleanArray.flatMapIndexed(     transform: (index: Int, Boolean) -> Iterable<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.BooleanArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.flatMapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.collections.Iterable((kotlin.collections.flatMapIndexedTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> BooleanArray.flatMapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> Iterable<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.BooleanArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.flatMapTo.C,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.Iterable((kotlin.collections.flatMapTo.R)))))/destination). ``` fun <R, C : MutableCollection<in R>> BooleanArray.flatMapTo(     destination: C,     transform: (Boolean) -> Iterable<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.BooleanArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Boolean,%20)))/initial) value and applying [operation](../../kotlin.collections/fold#kotlin.collections%24fold(kotlin.BooleanArray,%20kotlin.collections.fold.R,%20kotlin.Function2((kotlin.collections.fold.R,%20kotlin.Boolean,%20)))/operation) from left to right to current accumulator value and each element. ``` fun <R> BooleanArray.fold(     initial: R,     operation: (acc: R, Boolean) -> 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.BooleanArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Boolean,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-indexed#kotlin.collections%24foldIndexed(kotlin.BooleanArray,%20kotlin.collections.foldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.foldIndexed.R,%20kotlin.Boolean,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun <R> BooleanArray.foldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> 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.BooleanArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Boolean,%20kotlin.collections.foldRight.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right#kotlin.collections%24foldRight(kotlin.BooleanArray,%20kotlin.collections.foldRight.R,%20kotlin.Function2((kotlin.Boolean,%20kotlin.collections.foldRight.R,%20)))/operation) from right to left to each element and current accumulator value. ``` fun <R> BooleanArray.foldRight(     initial: R,     operation: (Boolean, 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.BooleanArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%20kotlin.collections.foldRightIndexed.R,%20)))/initial) value and applying [operation](../../kotlin.collections/fold-right-indexed#kotlin.collections%24foldRightIndexed(kotlin.BooleanArray,%20kotlin.collections.foldRightIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%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> BooleanArray.foldRightIndexed(     initial: R,     operation: (index: Int, Boolean, 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Unit)))/action) on each element. ``` fun BooleanArray.forEach(action: (Boolean) -> 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.BooleanArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.Unit)))/action) on each element, providing sequential index with the element. ``` fun BooleanArray.forEachIndexed(     action: (index: Int, Boolean) -> 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.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/index) or the result of calling the [defaultValue](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/defaultValue) function if the [index](../../kotlin.collections/get-or-else#kotlin.collections%24getOrElse(kotlin.BooleanArray,%20kotlin.Int,%20kotlin.Function1((kotlin.Int,%20kotlin.Boolean)))/index) is out of bounds of this array. ``` fun BooleanArray.getOrElse(     index: Int,     defaultValue: (Int) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Int)/index) or `null` if the [index](../../kotlin.collections/get-or-null#kotlin.collections%24getOrNull(kotlin.BooleanArray,%20kotlin.Int)/index) is out of bounds of this array. ``` fun BooleanArray.getOrNull(index: Int): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%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> BooleanArray.groupBy(     keySelector: (Boolean) -> K ): Map<K, List<Boolean>> ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by#kotlin.collections%24groupBy(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupBy.K)),%20kotlin.Function1((kotlin.Boolean,%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> BooleanArray.groupBy(     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> 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.BooleanArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.K)))/keySelector) function applied to each element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.BooleanArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.K)))/destination) map each group key associated with a list of corresponding elements. ``` fun <K, M : MutableMap<in K, MutableList<Boolean>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K ): M ``` Groups values returned by the [valueTransform](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.BooleanArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.V)))/keySelector) function applied to the element and puts to the [destination](../../kotlin.collections/group-by-to#kotlin.collections%24groupByTo(kotlin.BooleanArray,%20kotlin.collections.groupByTo.M,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.groupByTo.K)),%20kotlin.Function1((kotlin.Boolean,%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>>> BooleanArray.groupByTo(     destination: M,     keySelector: (Boolean) -> K,     valueTransform: (Boolean) -> V ): M ``` **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.BooleanArray,%20kotlin.Boolean)/element), or -1 if the array does not contain element. ``` fun BooleanArray.indexOf(element: Boolean): 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or -1 if the array does not contain such element. ``` fun BooleanArray.indexOfFirst(     predicate: (Boolean) -> 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or -1 if the array does not contain such element. ``` fun BooleanArray.indexOfLast(     predicate: (Boolean) -> 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 array and the specified collection. ``` infix fun BooleanArray.intersect(     other: Iterable<Boolean> ): Set<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isEmpty](../../kotlin.collections/is-empty) Returns `true` if the array is empty. ``` fun BooleanArray.isEmpty(): Boolean ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isNotEmpty](../../kotlin.collections/is-not-empty) Returns `true` if the array is not empty. ``` fun BooleanArray.isNotEmpty(): 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.BooleanArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.BooleanArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to#kotlin.collections%24joinTo(kotlin.BooleanArray,%20kotlin.collections.joinTo.A,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun <A : Appendable> BooleanArray.joinTo(     buffer: A,     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> 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.BooleanArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/separator) and using the given [prefix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.BooleanArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/prefix) and [postfix](../../kotlin.collections/join-to-string#kotlin.collections%24joinToString(kotlin.BooleanArray,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.CharSequence,%20kotlin.Int,%20kotlin.CharSequence,%20kotlin.Function1?((kotlin.Boolean,%20kotlin.CharSequence)))/postfix) if supplied. ``` fun BooleanArray.joinToString(     separator: CharSequence = ", ",     prefix: CharSequence = "",     postfix: CharSequence = "",     limit: Int = -1,     truncated: CharSequence = "...",     transform: ((Boolean) -> 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 BooleanArray.last(): Boolean ``` Returns the last element matching the given [predicate](../../kotlin.collections/last#kotlin.collections%24last(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.last(     predicate: (Boolean) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Boolean)/element), or -1 if the array does not contain element. ``` fun BooleanArray.lastIndexOf(element: Boolean): 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 BooleanArray.lastOrNull(): Boolean? ``` Returns the last element matching the given [predicate](../../kotlin.collections/last-or-null#kotlin.collections%24lastOrNull(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or `null` if no such element was found. ``` fun BooleanArray.lastOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.map.R)))/transform) function to each element in the original array. ``` fun <R> BooleanArray.map(transform: (Boolean) -> 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.BooleanArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.collections.mapIndexed.R)))/transform) function to each element and its index in the original array. ``` fun <R> BooleanArray.mapIndexed(     transform: (index: Int, Boolean) -> R ): List<R> ``` **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.BooleanArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.mapIndexedTo.C,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.collections.mapIndexedTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> BooleanArray.mapIndexedTo(     destination: C,     transform: (index: Int, Boolean) -> 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.BooleanArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.mapTo.C,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.mapTo.R)))/destination). ``` fun <R, C : MutableCollection<in R>> BooleanArray.mapTo(     destination: C,     transform: (Boolean) -> 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>> BooleanArray.maxByOrNull(     selector: (Boolean) -> R ): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.maxOf(     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.maxOfOrNull(     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.maxOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with#kotlin.collections%24maxOfWith(kotlin.BooleanArray,%20kotlin.Comparator((kotlin.collections.maxOfWith.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.maxOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> BooleanArray.maxOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.maxOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/max-of-with-or-null#kotlin.collections%24maxOfWithOrNull(kotlin.BooleanArray,%20kotlin.Comparator((kotlin.collections.maxOfWithOrNull.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.maxOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> BooleanArray.maxOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` #### [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.BooleanArray,%20kotlin.Comparator((kotlin.Boolean)))/comparator). ``` fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` fun BooleanArray.maxWith(     comparator: Comparator<in Boolean> ): Boolean? ``` **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.BooleanArray,%20kotlin.Comparator((kotlin.Boolean)))/comparator) or `null` if there are no elements. ``` fun BooleanArray.maxWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` **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>> BooleanArray.minByOrNull(     selector: (Boolean) -> R ): Boolean? ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun <R : Comparable<R>> any_array<R>.minOf(     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Double)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R : Comparable<R>> any_array<R>.minOfOrNull(     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.minOfWith.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with#kotlin.collections%24minOfWith(kotlin.BooleanArray,%20kotlin.Comparator((kotlin.collections.minOfWith.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.minOfWith.R)))/selector) function applied to each element in the array. ``` fun <R> BooleanArray.minOfWith(     comparator: Comparator<in R>,     selector: (Boolean) -> 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.BooleanArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.minOfWithOrNull.R)))/comparator) among all values produced by [selector](../../kotlin.collections/min-of-with-or-null#kotlin.collections%24minOfWithOrNull(kotlin.BooleanArray,%20kotlin.Comparator((kotlin.collections.minOfWithOrNull.R)),%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.minOfWithOrNull.R)))/selector) function applied to each element in the array or `null` if there are no elements. ``` fun <R> BooleanArray.minOfWithOrNull(     comparator: Comparator<in R>,     selector: (Boolean) -> R ): R? ``` #### [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.BooleanArray,%20kotlin.Comparator((kotlin.Boolean)))/comparator). ``` fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean ``` **Platform and version requirements:** JVM (1.0) ``` fun BooleanArray.minWith(     comparator: Comparator<in Boolean> ): Boolean? ``` **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.BooleanArray,%20kotlin.Comparator((kotlin.Boolean)))/comparator) or `null` if there are no elements. ``` fun BooleanArray.minWithOrNull(     comparator: Comparator<in Boolean> ): Boolean? ``` **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 BooleanArray.none(): Boolean ``` Returns `true` if no elements match the given [predicate](../../kotlin.collections/none#kotlin.collections%24none(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.none(     predicate: (Boolean) -> Boolean ): Boolean ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [onEach](../../kotlin.collections/on-each) Performs the given [action](../../kotlin.collections/on-each#kotlin.collections%24onEach(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Unit)))/action) on each element and returns the array itself afterwards. ``` fun BooleanArray.onEach(     action: (Boolean) -> Unit ): BooleanArray ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Int,%20kotlin.Boolean,%20kotlin.Unit)))/action) on each element, providing sequential index with the element, and returns the array itself afterwards. ``` fun BooleanArray.onEachIndexed(     action: (index: Int, Boolean) -> Unit ): BooleanArray ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [partition](../../kotlin.collections/partition) Splits the original array into pair of lists, where *first* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate) yielded `true`, while *second* list contains elements for which [predicate](../../kotlin.collections/partition#kotlin.collections%24partition(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate) yielded `false`. ``` fun BooleanArray.partition(     predicate: (Boolean) -> Boolean ): Pair<List<Boolean>, List<Boolean>> ``` **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 BooleanArray.random(): Boolean ``` Returns a random element from this array using the specified source of randomness. ``` fun BooleanArray.random(random: Random): Boolean ``` **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 BooleanArray.randomOrNull(): Boolean? ``` Returns a random element from this array using the specified source of randomness, or `null` if this array is empty. ``` fun BooleanArray.randomOrNull(random: Random): Boolean? ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun BooleanArray.reduce(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun BooleanArray.reduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%20,%20)))/operation) from left to right to current accumulator value and each element with its index in the original array. ``` fun BooleanArray.reduceIndexedOrNull(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20)))/operation) from left to right to current accumulator value and each element. ``` fun BooleanArray.reduceOrNull(     operation: (acc: Boolean, Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun BooleanArray.reduceRight(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun BooleanArray.reduceRightIndexed(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean ``` **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.BooleanArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%20,%20)))/operation) from right to left to each element with its index in the original array and current accumulator value. ``` fun BooleanArray.reduceRightIndexedOrNull(     operation: (index: Int, Boolean, acc: Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20)))/operation) from right to left to each element and current accumulator value. ``` fun BooleanArray.reduceRightOrNull(     operation: (Boolean, acc: Boolean) -> Boolean ): Boolean? ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reverse](../../kotlin.collections/reverse) Reverses elements in the array in-place. ``` fun BooleanArray.reverse() ``` Reverses elements of the array in the specified range in-place. ``` fun BooleanArray.reverse(fromIndex: Int, toIndex: Int) ``` **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 BooleanArray.reversed(): List<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [reversedArray](../../kotlin.collections/reversed-array) Returns an array with elements of this array in reversed order. ``` fun BooleanArray.reversedArray(): BooleanArray ``` **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.BooleanArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.runningFold.R,%20kotlin.Function2((kotlin.collections.runningFold.R,%20kotlin.Boolean,%20)))/initial) value. ``` fun <R> BooleanArray.runningFold(     initial: R,     operation: (acc: R, Boolean) -> 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.BooleanArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.runningFoldIndexed.R,%20kotlin.Boolean,%20)))/initial) value. ``` fun <R> BooleanArray.runningFoldIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> 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.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20)))/operation) from left to right to each element and current accumulator value that starts with the first element of this array. ``` fun BooleanArray.runningReduce(     operation: (acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function3((kotlin.Int,%20kotlin.Boolean,%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 BooleanArray.runningReduceIndexed(     operation: (index: Int, acc: Boolean, Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Boolean,%20)))/operation) from left to right to each element and current accumulator value that starts with [initial](../../kotlin.collections/scan#kotlin.collections%24scan(kotlin.BooleanArray,%20kotlin.collections.scan.R,%20kotlin.Function2((kotlin.collections.scan.R,%20kotlin.Boolean,%20)))/initial) value. ``` fun <R> BooleanArray.scan(     initial: R,     operation: (acc: R, Boolean) -> 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.BooleanArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.scanIndexed.R,%20kotlin.Function3((kotlin.Int,%20kotlin.collections.scanIndexed.R,%20kotlin.Boolean,%20)))/initial) value. ``` fun <R> BooleanArray.scanIndexed(     initial: R,     operation: (index: Int, acc: R, Boolean) -> 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 BooleanArray.shuffle() ``` Randomly shuffles elements in this array in-place using the specified [random](../../kotlin.collections/shuffle#kotlin.collections%24shuffle(kotlin.BooleanArray,%20kotlin.random.Random)/random) instance as the source of randomness. ``` fun BooleanArray.shuffle(random: Random) ``` **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 BooleanArray.single(): Boolean ``` Returns the single element matching the given [predicate](../../kotlin.collections/single#kotlin.collections%24single(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or throws exception if there is no or more than one matching element. ``` fun BooleanArray.single(     predicate: (Boolean) -> Boolean ): Boolean ``` **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 BooleanArray.singleOrNull(): Boolean? ``` Returns the single element matching the given [predicate](../../kotlin.collections/single-or-null#kotlin.collections%24singleOrNull(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate), or `null` if element was not found or more than one element was found. ``` fun BooleanArray.singleOrNull(     predicate: (Boolean) -> Boolean ): Boolean? ``` **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.BooleanArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun BooleanArray.slice(indices: IntRange): List<Boolean> ``` Returns a list containing elements at specified [indices](../../kotlin.collections/slice#kotlin.collections%24slice(kotlin.BooleanArray,%20kotlin.collections.Iterable((kotlin.Int)))/indices). ``` fun BooleanArray.slice(indices: Iterable<Int>): List<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [sliceArray](../../kotlin.collections/slice-array) Returns an array containing elements of this array at specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.BooleanArray,%20kotlin.collections.Collection((kotlin.Int)))/indices). ``` fun BooleanArray.sliceArray(     indices: Collection<Int> ): BooleanArray ``` Returns an array containing elements at indices in the specified [indices](../../kotlin.collections/slice-array#kotlin.collections%24sliceArray(kotlin.BooleanArray,%20kotlin.ranges.IntRange)/indices) range. ``` fun BooleanArray.sliceArray(indices: IntRange): BooleanArray ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.sortedBy.R?)))/selector) function. ``` fun <R : Comparable<R>> BooleanArray.sortedBy(     selector: (Boolean) -> R? ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.collections.sortedByDescending.R?)))/selector) function. ``` fun <R : Comparable<R>> BooleanArray.sortedByDescending(     selector: (Boolean) -> R? ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Comparator((kotlin.Boolean)))/comparator). ``` fun BooleanArray.sortedWith(     comparator: Comparator<in Boolean> ): List<Boolean> ``` **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 array and not contained by the specified collection. ``` infix fun BooleanArray.subtract(     other: Iterable<Boolean> ): Set<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Int)))/selector) function applied to each element in the array. ``` fun BooleanArray.sumBy(selector: (Boolean) -> 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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20kotlin.Double)))/selector) function applied to each element in the array. ``` fun BooleanArray.sumByDouble(     selector: (Boolean) -> Double ): Double ``` #### [sumOf](../../kotlin.collections/sum-of) Returns the sum of all values produced by [selector](../../kotlin.collections/sum-of#kotlin.collections%24sumOf(kotlin.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%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 BooleanArray.sumOf(selector: (Boolean) -> Double): Double ``` **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 BooleanArray.sumOf(selector: (Boolean) -> Long): Long ``` **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 BooleanArray.sumOf(selector: (Boolean) -> ULong): ULong ``` **Platform and version requirements:** JVM (1.4) ``` fun BooleanArray.sumOf(     selector: (Boolean) -> BigDecimal ): BigDecimal ``` **Platform and version requirements:** JVM (1.4) ``` fun BooleanArray.sumOf(     selector: (Boolean) -> BigInteger ): BigInteger ``` **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.BooleanArray,%20kotlin.Int)/n) elements. ``` fun BooleanArray.take(n: Int): List<Boolean> ``` **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.BooleanArray,%20kotlin.Int)/n) elements. ``` fun BooleanArray.takeLast(n: Int): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.takeLastWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.Function1((kotlin.Boolean,%20)))/predicate). ``` fun BooleanArray.takeWhile(     predicate: (Boolean) -> Boolean ): List<Boolean> ``` **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.BooleanArray,%20kotlin.collections.toCollection.C)/destination) collection. ``` fun <C : MutableCollection<in Boolean>> BooleanArray.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 BooleanArray.toHashSet(): HashSet<Boolean> ``` **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 BooleanArray.toList(): List<Boolean> ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toMutableList](../../kotlin.collections/to-mutable-list) Returns a new [MutableList](../../kotlin.collections/-mutable-list/index#kotlin.collections.MutableList) filled with all elements of this array. ``` fun BooleanArray.toMutableList(): MutableList<Boolean> ``` **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 array. ``` fun BooleanArray.toMutableSet(): MutableSet<Boolean> ``` **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 BooleanArray.toSet(): Set<Boolean> ``` **Platform and version requirements:** JVM (1.0) #### [toSortedSet](../../kotlin.collections/to-sorted-set) Returns a new [SortedSet](https://docs.oracle.com/javase/8/docs/api/java/util/SortedSet.html) of all elements. ``` fun BooleanArray.toSortedSet(): SortedSet<Boolean> ``` **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 BooleanArray.union(     other: Iterable<Boolean> ): Set<Boolean> ``` **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 array into an [IndexedValue](../../kotlin.collections/-indexed-value/index) containing the index of that element and the element itself. ``` fun BooleanArray.withIndex(): Iterable<IndexedValue<Boolean>> ``` **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.BooleanArray,%20kotlin.Array((kotlin.collections.zip.R)))/other) array with the same index. The returned list has length of the shortest collection. ``` infix fun <R> any_array<R>.zip(     other: Array<out R> ): List<Pair<Boolean, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.BooleanArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Boolean,%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.BooleanArray,%20kotlin.Array((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Boolean,%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> BooleanArray.zip(     other: Array<out R>,     transform: (a: Boolean, 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.BooleanArray,%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> BooleanArray.zip(     other: Iterable<R> ): List<Pair<Boolean, R>> ``` Returns a list of values built from the elements of `this` array and the [other](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.BooleanArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Boolean,%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.BooleanArray,%20kotlin.collections.Iterable((kotlin.collections.zip.R)),%20kotlin.Function2((kotlin.Boolean,%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> BooleanArray.zip(     other: Iterable<R>,     transform: (a: Boolean, 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.BooleanArray,%20kotlin.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20kotlin.collections.zip.V)))/other) array with the same index using the provided [transform](../../kotlin.collections/zip#kotlin.collections%24zip(kotlin.BooleanArray,%20kotlin.BooleanArray,%20kotlin.Function2((kotlin.Boolean,%20,%20kotlin.collections.zip.V)))/transform) function applied to each pair of elements. The returned list has length of the shortest array. ``` fun <V> BooleanArray.zip(     other: BooleanArray,     transform: (a: Boolean, b: Boolean) -> V ): List<V> ```
programming_docs
kotlin iterator iterator ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) / <iterator> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun iterator(): BooleanIterator ``` Creates an iterator over the elements of the array. kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int, init: (Int) -> Boolean) ``` Creates a new array of the specified size, where each element is calculated by calling the specified init function. The function init is called for each array element sequentially starting from the first one. It should return the value for an array element given its index. **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` <init>(size: Int) ``` Creates a new array of the specified [size](size#kotlin.BooleanArray%24size), with all elements initialized to `false`. **Constructor** Creates a new array of the specified [size](size#kotlin.BooleanArray%24size), with all elements initialized to `false`. kotlin set set === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) / <set> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun set(index: Int, value: Boolean) ``` ##### For Common, JVM, JS Sets the element at the given [index](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/index) to the given [value](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/value). This method can be called using the index operator. If the [index](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/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. ##### For Native Sets the element at the given [index](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/index) to the given [value](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/value). This method can be called using the index operator. If the [index](set#kotlin.BooleanArray%24set(kotlin.Int,%20kotlin.Boolean)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin get get === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [BooleanArray](index) / <get> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun get(index: Int): Boolean ``` ##### For Common, JVM, JS Returns the array element at the given [index](get#kotlin.BooleanArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.BooleanArray%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. ##### For Native Returns the array element at the given [index](get#kotlin.BooleanArray%24get(kotlin.Int)/index). This method can be called using the index operator. If the [index](get#kotlin.BooleanArray%24get(kotlin.Int)/index) is out of bounds of this array, throws an [IndexOutOfBoundsException](../-index-out-of-bounds-exception/index#kotlin.IndexOutOfBoundsException). kotlin DslMarker DslMarker ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [DslMarker](index) **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` @Target([AnnotationTarget.ANNOTATION_CLASS]) annotation class DslMarker ``` When applied to annotation class X specifies that X defines a DSL language The general rule: * an implicit receiver may *belong to a DSL @X* if marked with a corresponding DSL marker annotation * two implicit receivers of the same DSL are not accessible in the same scope * the closest one wins * other available receivers are resolved as usual, but if the resulting resolved call binds to such a receiver, it's a compilation error Marking rules: an implicit receiver is considered marked with @Ann if * its type is marked, or * its type's classifier is marked * or any of its superclasses/superinterfaces Constructors ------------ **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [<init>](-init-) When applied to annotation class X specifies that X defines a DSL language ``` <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) / [DslMarker](index) / [<init>](-init-) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` <init>() ``` When applied to annotation class X specifies that X defines a DSL language The general rule: * an implicit receiver may *belong to a DSL @X* if marked with a corresponding DSL marker annotation * two implicit receivers of the same DSL are not accessible in the same scope * the closest one wins * other available receivers are resolved as usual, but if the resulting resolved call binds to such a receiver, it's a compilation error Marking rules: an implicit receiver is considered marked with @Ann if * its type is marked, or * its type's classifier is marked * or any of its superclasses/superinterfaces kotlin Lazy Lazy ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Lazy](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` interface Lazy<out T> ``` Represents a value with lazy initialization. To create an instance of [Lazy](index) use the [lazy](../lazy#kotlin%24lazy(kotlin.Function0((kotlin.lazy.T)))) function. Properties ---------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <value> Gets the lazily initialized value of the current Lazy instance. Once the value was initialized it must not change during the rest of lifetime of this Lazy instance. ``` abstract val value: T ``` Functions --------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [isInitialized](is-initialized) Returns `true` if a value for this Lazy instance has been already initialized, and `false` otherwise. Once this function has returned `true` it stays `true` for the rest of lifetime of this Lazy instance. ``` abstract fun isInitialized(): Boolean ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [getValue](../get-value) An extension to delegate a read-only property of type [T](../get-value#T) to an instance of [Lazy](index). ``` operator fun <T> Lazy<T>.getValue(     thisRef: Any?,     property: KProperty<*> ): T ``` kotlin isInitialized isInitialized ============= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Lazy](index) / [isInitialized](is-initialized) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract fun isInitialized(): Boolean ``` Returns `true` if a value for this Lazy instance has been already initialized, and `false` otherwise. Once this function has returned `true` it stays `true` for the rest of lifetime of this Lazy instance. kotlin value value ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Lazy](index) / <value> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` abstract val value: T ``` Gets the lazily initialized value of the current Lazy instance. Once the value was initialized it must not change during the rest of lifetime of this Lazy instance. kotlin IllegalStateException IllegalStateException ===================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IllegalStateException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class IllegalStateException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias IllegalStateException = IllegalStateException ``` 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> ``` Inheritors ---------- #### [CancellationException](../../kotlin.coroutines.cancellation/-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 ``` kotlin <init> <init> ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [IllegalStateException](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) / [Double](index) / [SIZE\_BITS](-s-i-z-e_-b-i-t-s) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` const val SIZE_BITS: Int ``` The number of bits used to represent an instance of Double in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Converts this [Double](index#kotlin.Double) value to [Int](../-int/index#kotlin.Int). The fractional part, if any, is rounded down towards zero. Returns zero if this `Double` value is `NaN`, [Int.MIN\_VALUE](../-int/-m-i-n_-v-a-l-u-e#kotlin.Int.Companion%24MIN_VALUE) if it's less than `Int.MIN_VALUE`, [Int.MAX\_VALUE](../-int/-m-a-x_-v-a-l-u-e#kotlin.Int.Companion%24MAX_VALUE) if it's bigger than `Int.MAX_VALUE`. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.3", "1.5") fun toByte(): Byte ``` **Deprecated:** Unclear conversion. To achieve the same result convert to Int explicitly and then to Byte. Converts this [Double](index#kotlin.Double) value to [Byte](../-byte/index#kotlin.Byte). The resulting `Byte` value is equal to `this.toInt().toByte()`. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Double ``` Returns this value. kotlin NaN NaN === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [NaN](-na-n) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val NaN: Double ``` A constant holding the "not a number" value of Double. kotlin Double Double ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Double : Number, Comparable<Double> ``` ##### For Common, JVM, JS 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`. ##### For Native Represents a double-precision 64-bit IEEE 754 floating point number. Functions --------- **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(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### <div> Divides this value by the other value. ``` operator fun div(other: Byte): Double ``` ``` operator fun div(other: Short): Double ``` ``` operator fun div(other: Int): Double ``` ``` operator fun div(other: Long): Double ``` ``` operator fun div(other: Float): Double ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Double): 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(): Double ``` **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): Double ``` ``` operator fun minus(other: Short): Double ``` ``` operator fun minus(other: Int): Double ``` ``` operator fun minus(other: Long): Double ``` ``` operator fun minus(other: Float): Double ``` ``` operator fun minus(other: Double): Double ``` **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): Double ``` ``` operator fun plus(other: Short): Double ``` ``` operator fun plus(other: Int): Double ``` ``` operator fun plus(other: Long): Double ``` ``` operator fun plus(other: Float): Double ``` ``` operator fun plus(other: Double): Double ``` **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): Double ``` ``` operator fun rem(other: Short): Double ``` ``` operator fun rem(other: Int): Double ``` ``` operator fun rem(other: Long): Double ``` ``` operator fun rem(other: Float): Double ``` ``` operator fun rem(other: Double): Double ``` **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): Double ``` ``` operator fun times(other: Short): Double ``` ``` operator fun times(other: Int): Double ``` ``` operator fun times(other: Long): Double ``` ``` operator fun times(other: Float): Double ``` ``` operator fun times(other: Double): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Converts this [Double](index#kotlin.Double) 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 [Double](index#kotlin.Double) 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) Returns this value. ``` fun toDouble(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toFloat](to-float) Converts this [Double](index#kotlin.Double) 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 [Double](index#kotlin.Double) 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 [Double](index#kotlin.Double) 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 [Double](index#kotlin.Double) 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(): Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Double ``` 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 largest positive finite value of Double. ``` const val MAX_VALUE: Double ``` **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 smallest *positive* nonzero value of Double. ``` const val MIN_VALUE: Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NaN](-na-n) A constant holding the "not a number" value of Double. ``` const val NaN: Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [NEGATIVE\_INFINITY](-n-e-g-a-t-i-v-e_-i-n-f-i-n-i-t-y) A constant holding the negative infinity value of Double. ``` const val NEGATIVE_INFINITY: Double ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [POSITIVE\_INFINITY](-p-o-s-i-t-i-v-e_-i-n-f-i-n-i-t-y) A constant holding the positive infinity value of Double. ``` const val POSITIVE_INFINITY: Double ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [SIZE\_BITS](-s-i-z-e_-b-i-t-s) The number of bits used to represent an instance of Double in a binary form. ``` const val SIZE_BITS: Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) The number of bytes used to represent an instance of Double 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 [Double](index#kotlin.Double) number of days. ``` val Double.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 [Double](index#kotlin.Double) number of hours. ``` val Double.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 [Double](index#kotlin.Double) number of microseconds. ``` val Double.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 [Double](index#kotlin.Double) number of milliseconds. ``` val Double.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 [Double](index#kotlin.Double) number of minutes. ``` val Double.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 [Double](index#kotlin.Double) number of nanoseconds. ``` val Double.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 [Double](index#kotlin.Double) number of seconds. ``` val Double.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.Double,%20kotlin.Double)/minimumValue). ``` fun Double.coerceAtLeast(minimumValue: Double): Double ``` ``` 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.Double,%20kotlin.Double)/maximumValue). ``` fun Double.coerceAtMost(maximumValue: Double): Double ``` ``` 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.Double,%20kotlin.Double,%20kotlin.Double)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Double,%20kotlin.Double,%20kotlin.Double)/maximumValue). ``` fun Double.coerceIn(     minimumValue: Double,     maximumValue: Double ): Double ``` ``` 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:** 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 Double.mod(other: Float): Double ``` ``` fun Double.mod(other: Double): Double ``` **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 [Double](index#kotlin.Double) value to the specified [that](../../kotlin.ranges/range-to#kotlin.ranges%24rangeTo(kotlin.Double,%20kotlin.Double)/that) value. ``` operator fun Double.rangeTo(     that: Double ): ClosedFloatingPointRange<Double> ``` 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 [Double](index#kotlin.Double) value to the specified [that](../../kotlin.ranges/range-until#kotlin.ranges%24rangeUntil(kotlin.Double,%20kotlin.Double)/that) value. ``` operator fun Double.rangeUntil(     that: Double ): OpenEndRange<Double> ``` 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.6), JS (1.6), Native (1.6) #### [times](../../kotlin.time/times) Returns a duration whose value is the specified [duration](../../kotlin.time/times#kotlin.time%24times(kotlin.Double,%20kotlin.time.Duration)/duration) value multiplied by this number. ``` operator fun Double.times(duration: Duration): Duration ``` **Platform and version requirements:** JVM (1.2) #### [toBigDecimal](../to-big-decimal) Returns the value of this [Double](index#kotlin.Double) number as a [BigDecimal](https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html). ``` fun Double.toBigDecimal(): BigDecimal ``` ``` fun Double.toBigDecimal(mathContext: MathContext): BigDecimal ``` **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 [Double](index#kotlin.Double) number of the specified [unit](../../kotlin.time/to-duration#kotlin.time%24toDuration(kotlin.Double,%20kotlin.time.DurationUnit)/unit). ``` fun Double.toDuration(unit: DurationUnit): Duration ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Double](index#kotlin.Double) value to [UInt](../-u-int/index). ``` fun Double.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Double](index#kotlin.Double) value to [ULong](../-u-long/index). ``` fun Double.toULong(): ULong ```
programming_docs
kotlin SIZE_BYTES SIZE\_BYTES =========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [SIZE\_BYTES](-s-i-z-e_-b-y-t-e-s) **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) ``` const val SIZE_BYTES: Int ``` The number of bytes used to represent an instance of Double in a binary form. kotlin MIN_VALUE MIN\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](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: Double ``` A constant holding the smallest *positive* nonzero value of Double. kotlin toLong toLong ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toLong](to-long) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toLong(): Long ``` Converts this [Double](index#kotlin.Double) value to [Long](../-long/index#kotlin.Long). The fractional part, if any, is rounded down towards zero. Returns zero if this `Double` value is `NaN`, [Long.MIN\_VALUE](../-long/-m-i-n_-v-a-l-u-e#kotlin.Long.Companion%24MIN_VALUE) if it's less than `Long.MIN_VALUE`, [Long.MAX\_VALUE](../-long/-m-a-x_-v-a-l-u-e#kotlin.Long.Companion%24MAX_VALUE) if it's bigger than `Long.MAX_VALUE`. kotlin MAX_VALUE MAX\_VALUE ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](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: Double ``` A constant holding the largest positive finite value of Double. kotlin compareTo compareTo ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](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 rem rem === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <rem> **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) ``` operator fun rem(other: Byte): Double ``` ``` operator fun rem(other: Short): Double ``` ``` operator fun rem(other: Int): Double ``` ``` operator fun rem(other: Long): Double ``` ``` operator fun rem(other: Float): Double ``` ``` 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 div div === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <div> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun div(other: Byte): Double ``` ``` operator fun div(other: Short): Double ``` ``` operator fun div(other: Int): Double ``` ``` operator fun div(other: Long): Double ``` ``` operator fun div(other: Float): Double ``` ``` operator fun div(other: Double): Double ``` Divides this value by the other value. kotlin toDouble toDouble ======== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toDouble](to-double) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toDouble(): Double ``` Returns this value. kotlin dec dec === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <dec> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun dec(): Double ``` 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) / [Double](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 NEGATIVE_INFINITY NEGATIVE\_INFINITY ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [NEGATIVE\_INFINITY](-n-e-g-a-t-i-v-e_-i-n-f-i-n-i-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val NEGATIVE_INFINITY: Double ``` A constant holding the negative infinity value of Double. kotlin inc inc === [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <inc> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun inc(): Double ``` 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) / [Double](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) / [Double](index) / [unaryMinus](unary-minus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryMinus(): Double ``` Returns the negative of this value. kotlin equals equals ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](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: Double): Boolean ``` kotlin POSITIVE_INFINITY POSITIVE\_INFINITY ================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [POSITIVE\_INFINITY](-p-o-s-i-t-i-v-e_-i-n-f-i-n-i-t-y) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` const val POSITIVE_INFINITY: Double ``` A constant holding the positive infinity value of Double. kotlin times times ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <times> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun times(other: Byte): Double ``` ``` operator fun times(other: Short): Double ``` ``` operator fun times(other: Int): Double ``` ``` operator fun times(other: Long): Double ``` ``` operator fun times(other: Float): Double ``` ``` operator fun times(other: Double): Double ``` Multiplies this value by the other value. kotlin toFloat toFloat ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toFloat](to-float) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toFloat(): Float ``` Converts this [Double](index#kotlin.Double) value to [Float](../-float/index#kotlin.Float). The resulting value is the closest `Float` to this `Double` value. In case when this `Double` 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) / [Double](index) / <minus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun minus(other: Byte): Double ``` ``` operator fun minus(other: Short): Double ``` ``` operator fun minus(other: Int): Double ``` ``` operator fun minus(other: Long): Double ``` ``` operator fun minus(other: Float): Double ``` ``` operator fun minus(other: Double): Double ``` Subtracts the other value from this value. kotlin toShort toShort ======= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / [toShort](to-short) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` @DeprecatedSinceKotlin("1.3", "1.5") fun toShort(): Short ``` **Deprecated:** Unclear conversion. To achieve the same result convert to Int explicitly and then to Short. Converts this [Double](index#kotlin.Double) value to [Short](../-short/index#kotlin.Short). The resulting `Short` value is equal to `this.toInt().toShort()`. kotlin plus plus ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](index) / <plus> **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) ``` operator fun plus(other: Byte): Double ``` ``` operator fun plus(other: Short): Double ``` ``` operator fun plus(other: Int): Double ``` ``` operator fun plus(other: Long): Double ``` ``` operator fun plus(other: Float): Double ``` ``` operator fun plus(other: Double): Double ``` Adds the other value to this value. kotlin toChar toChar ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Double](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 [Double](index#kotlin.Double) value to [Char](../-char/index#kotlin.Char). The resulting `Char` value is equal to `this.toInt().toChar()`. kotlin NoSuchElementException NoSuchElementException ====================== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [NoSuchElementException](index) **Platform and version requirements:** JS (1.1), Native (1.3) ``` open class NoSuchElementException : RuntimeException ``` **Platform and version requirements:** JVM (1.1) ``` typealias NoSuchElementException = NoSuchElementException ``` 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) / [NoSuchElementException](index) / [<init>](-init-) **Platform and version requirements:** JS (1.0), Native (1.0) ``` <init>() ``` ``` <init>(message: String?) ``` kotlin SIZE_BITS SIZE\_BITS ========== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](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 Byte in a binary form. kotlin toInt toInt ===== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toInt](to-int) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toInt(): Int ``` Converts this [Byte](index#kotlin.Byte) value to [Int](../-int/index#kotlin.Int). The resulting `Int` value represents the same numerical value as this `Byte`. The least significant 8 bits of the resulting `Int` value are the same as the bits of this `Byte` value, whereas the most significant 24 bits are filled with the sign bit of this value. kotlin toByte toByte ====== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [toByte](to-byte) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` fun toByte(): Byte ``` Returns this value. kotlin unaryPlus unaryPlus ========= [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) / [unaryPlus](unary-plus) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` operator fun unaryPlus(): Int ``` Returns this value. kotlin Byte Byte ==== [kotlin-stdlib](../../../../../../index) / [kotlin](../index) / [Byte](index) **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.3) ``` class Byte : Number, Comparable<Byte> ``` ##### For Common, JVM, JS Represents a 8-bit signed integer. On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`. ##### For Native Represents a 8-bit signed integer. Functions --------- **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(): Byte ``` **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): 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. ``` operator fun div(other: Float): Float ``` ``` operator fun div(other: Double): Double ``` #### <equals> **Platform and version requirements:** Native (1.3) ``` fun equals(other: Byte): 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(): Byte ``` **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): 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 ``` **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): 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 ``` **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.Byte%24rangeTo(kotlin.Byte)/other) value. ``` operator fun rangeTo(other: Byte): IntRange ``` ``` operator fun rangeTo(other: Short): IntRange ``` ``` operator fun rangeTo(other: Int): IntRange ``` ``` 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.Byte%24rangeUntil(kotlin.Byte)/other) value. ``` operator fun rangeUntil(other: Byte): IntRange ``` ``` operator fun rangeUntil(other: Short): IntRange ``` ``` operator fun rangeUntil(other: Int): IntRange ``` ``` 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): 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 ``` **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): 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 ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toByte](to-byte) Returns this value. ``` fun toByte(): Byte ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [toChar](to-char) Converts this [Byte](index#kotlin.Byte) 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 [Byte](index#kotlin.Byte) 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 [Byte](index#kotlin.Byte) 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 [Byte](index#kotlin.Byte) 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 [Byte](index#kotlin.Byte) 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 [Byte](index#kotlin.Byte) 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(): Int ``` **Platform and version requirements:** JVM (1.0), JS (1.0), Native (1.0) #### [unaryPlus](unary-plus) Returns this value. ``` operator fun unaryPlus(): Int ``` 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 Byte can have. ``` const val MAX_VALUE: Byte ``` **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 Byte can have. ``` const val MIN_VALUE: Byte ``` **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 Byte 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 Byte in a binary form. ``` const val SIZE_BYTES: Int ``` Extension Functions ------------------- **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [and](../../kotlin.experimental/and) Performs a bitwise AND operation between the two values. ``` infix fun Byte.and(other: Byte): Byte ``` **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.Byte,%20kotlin.Byte)/minimumValue). ``` fun Byte.coerceAtLeast(minimumValue: Byte): Byte ``` ``` 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.Byte,%20kotlin.Byte)/maximumValue). ``` fun Byte.coerceAtMost(maximumValue: Byte): Byte ``` ``` 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.Byte,%20kotlin.Byte,%20kotlin.Byte)/minimumValue)..[maximumValue](../../kotlin.ranges/coerce-in#kotlin.ranges%24coerceIn(kotlin.Byte,%20kotlin.Byte,%20kotlin.Byte)/maximumValue). ``` fun Byte.coerceIn(     minimumValue: Byte,     maximumValue: Byte ): Byte ``` ``` 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> Byte.convert(): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countLeadingZeroBits](../count-leading-zero-bits) Counts the number of consecutive most significant bits that are zero in the binary representation of this [Byte](index#kotlin.Byte) number. ``` fun Byte.countLeadingZeroBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countOneBits](../count-one-bits) Counts the number of set bits in the binary representation of this [Byte](index#kotlin.Byte) number. ``` fun Byte.countOneBits(): Int ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [countTrailingZeroBits](../count-trailing-zero-bits) Counts the number of consecutive least significant bits that are zero in the binary representation of this [Byte](index#kotlin.Byte) number. ``` fun Byte.countTrailingZeroBits(): Int ``` **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.Byte,%20kotlin.Byte)/to) value with the step -1. ``` infix fun Byte.downTo(to: Byte): IntProgression ``` ``` infix fun Byte.downTo(to: Int): IntProgression ``` ``` infix fun Byte.downTo(to: Long): LongProgression ``` ``` infix fun Byte.downTo(to: Short): IntProgression ``` **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 Byte.floorDiv(other: Byte): Int ``` ``` fun Byte.floorDiv(other: Short): Int ``` ``` fun Byte.floorDiv(other: Int): Int ``` ``` fun Byte.floorDiv(other: Long): Long ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [inv](../../kotlin.experimental/inv) Inverts the bits in this value. ``` fun Byte.inv(): Byte ``` **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 Byte.mod(other: Byte): Byte ``` ``` fun Byte.mod(other: Short): Short ``` ``` fun Byte.mod(other: Int): Int ``` ``` fun Byte.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.1), JS (1.1), Native (1.1) #### [or](../../kotlin.experimental/or) Performs a bitwise OR operation between the two values. ``` infix fun Byte.or(other: Byte): Byte ``` **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 [Byte](index#kotlin.Byte) number left by the specified [bitCount](../rotate-left#kotlin%24rotateLeft(kotlin.Byte,%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 Byte.rotateLeft(bitCount: Int): Byte ``` **Platform and version requirements:** JVM (1.6), JS (1.6), Native (1.6) #### [rotateRight](../rotate-right) Rotates the binary representation of this [Byte](index#kotlin.Byte) number right by the specified [bitCount](../rotate-right#kotlin%24rotateRight(kotlin.Byte,%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 Byte.rotateRight(bitCount: Int): Byte ``` **Platform and version requirements:** Native (1.3) #### [signExtend](../../kotlinx.cinterop/sign-extend) ``` fun <R : Number> Number.signExtend(): R ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeHighestOneBit](../take-highest-one-bit) Returns a number having a single bit set in the position of the most significant set bit of this [Byte](index#kotlin.Byte) number, or zero, if this number is zero. ``` fun Byte.takeHighestOneBit(): Byte ``` **Platform and version requirements:** JVM (1.4), JS (1.4), Native (1.4) #### [takeLowestOneBit](../take-lowest-one-bit) Returns a number having a single bit set in the position of the least significant set bit of this [Byte](index#kotlin.Byte) number, or zero, if this number is zero. ``` fun Byte.takeLowestOneBit(): Byte ``` **Platform and version requirements:** Native (1.3) #### [toBoolean](../../kotlinx.cinterop/to-boolean) ``` fun Byte.toBoolean(): Boolean ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUByte](../to-u-byte) Converts this [Byte](index#kotlin.Byte) value to [UByte](../-u-byte/index). ``` fun Byte.toUByte(): UByte ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUInt](../to-u-int) Converts this [Byte](index#kotlin.Byte) value to [UInt](../-u-int/index). ``` fun Byte.toUInt(): UInt ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toULong](../to-u-long) Converts this [Byte](index#kotlin.Byte) value to [ULong](../-u-long/index). ``` fun Byte.toULong(): ULong ``` **Platform and version requirements:** JVM (1.5), JS (1.5), Native (1.5) #### [toUShort](../to-u-short) Converts this [Byte](index#kotlin.Byte) value to [UShort](../-u-short/index). ``` fun Byte.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.Byte,%20kotlin.Byte)/to) value. ``` infix fun Byte.until(to: Byte): IntRange ``` ``` infix fun Byte.until(to: Int): IntRange ``` ``` infix fun Byte.until(to: Long): LongRange ``` ``` infix fun Byte.until(to: Short): IntRange ``` **Platform and version requirements:** JVM (1.1), JS (1.1), Native (1.1) #### [xor](../../kotlin.experimental/xor) Performs a bitwise XOR operation between the two values. ``` infix fun Byte.xor(other: Byte): Byte ```
programming_docs