Code block If statement error

Hi,
I’m trying to use if statement in code block but i got error : " ‘if’ statement can only be used in imperative language block, consider using an inline conditional instead?"
any idea whats wrong?
image

Hi @rinag,

Just a thought, can you try the operators greater than instead?
TryOperatorGreaterThan

Cheers,
Jowenn

1 Like

yea, like the error said, it needs to be in a imperative block. you can either do this:

r;    
x = [Imperative]
{
    if (r>0)
    {
        x = true;
    }
    else
    {
        x = false;
    }
    return x;
}

or

r>0?true:false

with that being said, it wouldnt be wise to return just true or false as it can be done in a more simpler node shown above.

3 Likes

Or keep it simpler - no need for imperative code here (though it might show up woth your actual use case):

r > 0 ? true : false;

1 Like