compareTo
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.0Samples
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
}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.1Samples
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
}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.0Samples
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
}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.3Samples
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
}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.8Samples
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
}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.8Samples
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
}