Cannot compare nullable (option) variable with true.

Summary

Take for instance this variable: Counter ?int.

If I wanted to check that this variable is null, I would do:
if (Counter = false)
So logically, if I wanted to check that this variable isn’t null, I should be able to do:
if (Counter = true)
However, it does not seem to work. It always returns false.

Is it intended behavior? Or am I missing something?

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Steps to Reproduce

  1. Have a nullable (option) variable, like such: ?type,
  2. Compare it with true in an if statement.

Expected Result

If the variable has a value, it should return true.

Observed Result

Even when the variable has a value, it returns false.

Platform(s)

Desktop (I expect all platforms to behave the same).

Island Code

0000-0000-0000

Bump.

try doing

if(Counter?):
     Print("its not false")


if (C := Counter?)
    then:
        Print("Counter? is {C}")
    else:
        Print("Counter is FALSE")

1 Like