Comparable

Common
JVM
JS
Native
1.0
interface Comparable<in T>
(Common source) (Native source)

Classes which inherit from this interface have a defined total ordering between their instances.

Functions

Common
JVM
JS
Native
1.0

compareTo

Compares this object with the specified object for order. Returns zero if this object is equal to the specified other object, a negative number if it's less than other, or a positive number if it's greater than other.

abstract operator fun compareTo(other: T): Int

Extension Functions

Common
JVM
JS
Native
1.0

coerceAtLeast

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

fun <T : Comparable<T>> T.coerceAtLeast(minimumValue: T): T
Common
JVM
JS
Native
1.0

coerceAtMost

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

fun <T : Comparable<T>> T.coerceAtMost(maximumValue: T): T
Common
JVM
JS
Native
1.0

coerceIn

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

fun <T : Comparable<T>> T.coerceIn(
    minimumValue: T?,
    maximumValue: T?
): T

Ensures that this value lies in the specified range.

fun <T : Comparable<T>> T.coerceIn(
    range: ClosedFloatingPointRange<T>
): T
fun <T : Comparable<T>> T.coerceIn(range: ClosedRange<T>): T
Common
JVM
JS
Native
1.6

compareTo

Compares this object with the specified object for order. Returns zero if this object is equal to the specified other object, a negative number if it's less than other, or a positive number if it's greater than other.

infix fun <T> Comparable<T>.compareTo(other: T): Int
Common
JVM
JS
Native
1.0

rangeTo

Creates a range from this Comparable value to the specified that value.

operator fun <T : Comparable<T>> T.rangeTo(
    that: T
): ClosedRange<T>
Common
JVM
JS
Native
1.9

rangeUntil

Creates an open-ended range from this Comparable value to the specified that value.

operator fun <T : Comparable<T>> T.rangeUntil(
    that: T
): OpenEndRange<T>

Inheritors

Common
JVM
JS
Native
1.0

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.

class Boolean : Comparable<Boolean>
Common
JVM
JS
Native
1.0

Byte

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>
Common
JVM
JS
Native
1.0

Char

Represents a 16-bit Unicode character.

class Char : Comparable<Char>
Common
JVM
JS
Native
1.9

ComparableTimeMark

A TimeMark that can be compared for difference with other time marks obtained from the same TimeSource.WithComparableMarks time source.

interface ComparableTimeMark : 
    TimeMark,
    Comparable<ComparableTimeMark>
Common
JVM
JS
Native
1.0

Double

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>
Common
JVM
JS
Native
1.6

Duration

Represents the amount of time one instant of time is away from another instant.

class Duration : Comparable<Duration>
Common
JVM
JS
Native
1.0

Enum

The common base class of all enum classes. See the Kotlin language documentation for more information on enum classes.

abstract class Enum<E : Enum<E>> : Comparable<E>
Common
JVM
JS
Native
1.0

Float

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>
Common
JVM
JS
Native
1.0

Int

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>
Common
JVM
JS
Native
1.1

KotlinVersion

Represents a version of the Kotlin standard library.

class KotlinVersion : Comparable<KotlinVersion>
Common
JVM
JS
Native
1.0

Long

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>
Common
JVM
JS
Native
1.0

Short

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>
Common
JVM
JS
Native
1.0

String

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
Common
JVM
JS
Native
1.5

UByte

class UByte : Comparable<UByte>
Common
JVM
JS
Native
1.5

UInt

class UInt : Comparable<UInt>
Common
JVM
JS
Native
1.5

ULong

class ULong : Comparable<ULong>
Common
JVM
JS
Native
1.5

UShort

class UShort : Comparable<UShort>