Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 833 Bytes

booleans.md

File metadata and controls

32 lines (24 loc) · 833 Bytes

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
}

{kotlin-runnable="true" kotlin-min-compiler-version="1.3"}

On JVM: nullable references to boolean objects are boxed similarly to numbers.

{type="note"}