Boolean
In this page:
Boolean
A Boolean holds either true or false and is the result of every comparison and logical expression. Booleans drive if statements and pattern match guards throughout Scala. Unlike some languages, Scala never implicitly converts other types to Boolean.
Note: Comparison operators like ==, >, and < always evaluate to a Boolean value.
Example: Boolean
object Main extends App {
val isActive: Boolean = true
val isAdmin: Boolean = false
val isAdult = 20 >= 18
println(s"$isActive $isAdmin $isAdult")
}
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 8 topics to unlock
0/8 topics done
Complete these topics first: