I was trying out below code:
val set1 = Set(1,2,3,4,5,67,8)
val TRUE_BOOLEAN = true
val FALSE_BOOLEAN = false
set1.contains(4) match {
case TRUE_BOOLEAN => println("Element found")
case FALSE_BOOLEAN => println("Element not found")
}
But, when i am trying to run it in IntelliJ, it is giving below warning in Messages tab:
Warning:(11, 16) match may not be exhaustive.
It would fail on the following inputs: false, true
set1.contains(4) match {
Whereas, if i use true and false instead of TRUE_BOOLEAN and FALSE_BOOLEAN, i am not getting any warning.
set1.contains(4) match {
case true => println("Element found")
case false => println("Element not found")
}
Can someone please explain the reason for this warning and why does it goes away with true and false.