Kotlin Help

Booleans

The type Boolean represents boolean objects that can have two values: true and false.

Boolean has a nullable counterpart Boolean? that also has the null value.

Built-in operations on booleans include:

  • || – disjunction (logical OR)

  • && – conjunction (logical AND)

  • ! – negation (logical NOT)

|| and && work lazily.

fun main() { //sampleStart val myTrue: Boolean = true val myFalse: Boolean = false val boolNull: Boolean? = null println(myTrue || myFalse) println(myTrue && myFalse) println(!myTrue) //sampleEnd }
Last modified: 10 August 2022