Package-level declarations

Ranges, Progressions and related top-level and extension functions.

Types

Link copied to clipboard

A progression of values of type Char.

Since Kotlin 1.0
Link copied to clipboard
class CharRange(start: Char, endInclusive: Char) : CharProgression, ClosedRange<Char> , OpenEndRange<Char>

A range of values of type Char.

Since Kotlin 1.0
Link copied to clipboard

Represents a range of floating point numbers. Extends ClosedRange interface providing custom operation lessThanOrEquals for comparing values of range domain type.

Since Kotlin 1.1
Link copied to clipboard
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 for more information.

Since Kotlin 1.0
Link copied to clipboard
open class IntProgression : Iterable<Int>

A progression of values of type Int.

Since Kotlin 1.0
Link copied to clipboard
class IntRange(start: Int, endInclusive: Int) : IntProgression, ClosedRange<Int> , OpenEndRange<Int>

A range of values of type Int.

Since Kotlin 1.0
Link copied to clipboard

A progression of values of type Long.

Since Kotlin 1.0
Link copied to clipboard
class LongRange(start: Long, endInclusive: Long) : LongProgression, ClosedRange<Long> , OpenEndRange<Long>

A range of values of type Long.

Since Kotlin 1.0
Link copied to clipboard
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 for more information.

Since Kotlin 1.9
Link copied to clipboard

A progression of values of type UInt.

Since Kotlin 1.5
Link copied to clipboard
class UIntRange(start: UInt, endInclusive: UInt) : UIntProgression, ClosedRange<UInt> , OpenEndRange<UInt>

A range of values of type UInt.

Since Kotlin 1.5
Link copied to clipboard

A progression of values of type ULong.

Since Kotlin 1.5
Link copied to clipboard

A range of values of type ULong.

Since Kotlin 1.5

Functions

Link copied to clipboard
fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
fun Byte.coerceAtLeast(minimumValue: Byte): Byte
fun Double.coerceAtLeast(minimumValue: Double): Double
fun Float.coerceAtLeast(minimumValue: Float): Float
fun Int.coerceAtLeast(minimumValue: Int): Int
fun Long.coerceAtLeast(minimumValue: Long): Long
fun Short.coerceAtLeast(minimumValue: Short): Short

Ensures that this value is not less than the specified minimumValue.

Since Kotlin 1.0
fun UByte.coerceAtLeast(minimumValue: UByte): UByte
fun UInt.coerceAtLeast(minimumValue: UInt): UInt
fun ULong.coerceAtLeast(minimumValue: ULong): ULong
fun UShort.coerceAtLeast(minimumValue: UShort): UShort

Ensures that this value is not less than the specified minimumValue.

Since Kotlin 1.5
Link copied to clipboard
fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
fun Byte.coerceAtMost(maximumValue: Byte): Byte
fun Double.coerceAtMost(maximumValue: Double): Double
fun Float.coerceAtMost(maximumValue: Float): Float
fun Int.coerceAtMost(maximumValue: Int): Int
fun Long.coerceAtMost(maximumValue: Long): Long
fun Short.coerceAtMost(maximumValue: Short): Short

Ensures that this value is not greater than the specified maximumValue.

Since Kotlin 1.0
fun UByte.coerceAtMost(maximumValue: UByte): UByte
fun UInt.coerceAtMost(maximumValue: UInt): UInt
fun ULong.coerceAtMost(maximumValue: ULong): ULong
fun UShort.coerceAtMost(maximumValue: UShort): UShort

Ensures that this value is not greater than the specified maximumValue.

Since Kotlin 1.5
Link copied to clipboard

Ensures that this value lies in the specified range.

Since Kotlin 1.1
fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T

Ensures that this value lies in the specified range.

Since Kotlin 1.0

Ensures that this value lies in the specified range.

Since Kotlin 1.5
fun <T : Comparable<T>> T.coerceIn(minimumValue: T?, maximumValue: T?): T
fun Byte.coerceIn(minimumValue: Byte, maximumValue: Byte): Byte
fun Double.coerceIn(minimumValue: Double, maximumValue: Double): Double
fun Float.coerceIn(minimumValue: Float, maximumValue: Float): Float
fun Int.coerceIn(minimumValue: Int, maximumValue: Int): Int
fun Long.coerceIn(minimumValue: Long, maximumValue: Long): Long
fun Short.coerceIn(minimumValue: Short, maximumValue: Short): Short

Ensures that this value lies in the specified range minimumValue..maximumValue.

Since Kotlin 1.0
fun UByte.coerceIn(minimumValue: UByte, maximumValue: UByte): UByte
fun UInt.coerceIn(minimumValue: UInt, maximumValue: UInt): UInt
fun ULong.coerceIn(minimumValue: ULong, maximumValue: ULong): ULong
fun UShort.coerceIn(minimumValue: UShort, maximumValue: UShort): UShort

Ensures that this value lies in the specified range minimumValue..maximumValue.

Since Kotlin 1.5
Link copied to clipboard
inline operator fun <T : Any, R : ClosedRange<T>, Iterable<T>> R.contains(element: T?): Boolean

Returns true if this iterable range contains the specified element.

Since Kotlin 1.3
inline operator fun <T : Any, R : OpenEndRange<T>, Iterable<T>> R.contains(element: T?): Boolean

Returns true if this iterable range contains the specified element.

Since Kotlin 1.9
inline operator fun CharRange.contains(element: Char?): Boolean
inline operator fun IntRange.contains(element: Int?): Boolean
inline operator fun LongRange.contains(element: Long?): Boolean

Returns true if this range contains the specified element.

Since Kotlin 1.3
@JvmName(name = "byteRangeContains")
operator fun ClosedRange<Byte>.contains(value: Double): Boolean
@JvmName(name = "byteRangeContains")
operator fun ClosedRange<Byte>.contains(value: Float): Boolean
@JvmName(name = "byteRangeContains")
operator fun