compareTo

expect open operator override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.0

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}
actual open operator override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.1

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}
actual open operator override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.0

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}
actual open operator external override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.3

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}
actual open operator override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.8

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}
actual open operator override fun compareTo(other: Boolean): Int(source)

Compares this Boolean with the specified Boolean for order. Returns zero if both are equal to each other, a negative number if this is false and other is true, or a positive number if this is true and other is false.

In other words, false is considered to be "less than" true.

Since Kotlin

1.8

Samples

import kotlin.test.assertTrue

fun main() { 
   //sampleStart 
   // false is equal to false, and true is equal to true
println(false.compareTo(false)) // 0
println(true.compareTo(true)) // 0

// But false is less than true, and true is greater than false
println(false.compareTo(true) < 0) // true
println(true.compareTo(false) > 0) // true 
   //sampleEnd
}