#Check if bool is not null and true (shorthand)?

1 messages · Page 1 of 1 (latest)

blissful valve
#

I have a variable var b: ?bool and want to check if it's both not null and true

I'm currently doing:
if (b != null and b) ...
Is there a shorthand way to do this?
I could also do if (b orelse false) but that seems less clear, to me.

#

Actually the first one doesn't even work

native coral
#

you can just do b == true

blissful valve
#

For an optional?

native coral
#

yes