If you want to cleanly check whether a Boolean? is true or false you can do:
when(b) {
true -> {}
false -> {}
}
If you want to check if it's null you can add that (or else) as a value in the when:
when(b) {
true -> {}
false -> {}
null -> {}
}
when(b) {
true -> {}
false -> {}
else-> {}
}