In programming, you often need a data type that can only have one of two values, like:
For this, Kotlin has a Boolean data type, which can take the values true or false.
val isKotlinFun: Boolean = true val isFishTasty: Boolean = false println(isKotlinFun) // Outputs true println(isFishTasty) // Outputs false
A Boolean expression is a Kotlin expression that evaluates to a Boolean value (true or false). You can use a comparison operator, such as the greater than (>) operator, to find out if an expression (or a variable) is true:
println(10 > 9) will output true because 10 is greater than 9.
Booleans are the foundation of logic and decision-making in your Kotlin code!