Just wondering about how this logic condition evaluates
-
I was expecting this statement to return "false" as soon as it detects that the "selected" variable is not an array. Instead it moves on to checking if the non-existent array contains a value.
Shouldn't it just return "false" instead of throwing an error?
-
@VirtualVirgin you need a set of parentheses around the two parts that belong to the && I think
-
@VirtualVirgin said in Just wondering about how this logic condition evaluates:
I was expecting this statement to return "false" as soon as it detects that the "selected" variable is not an array. Instead it moves on to checking if the non-existent array contains a value.
Shouldn't it just return "false" instead of throwing an error?
this is pretty poorly self-documenting code, separate it out into a set of if statements
-
@d-healey said in Just wondering about how this logic condition evaluates:
@VirtualVirgin you need a set of parentheses around the two parts that belong to the && I think
Yes! That is the solution :)
-
@VirtualVirgin said in Just wondering about how this logic condition evaluates:
Yes! That is the solution :)
You can probably also get rid of the ternary operator at the end -
? true : false
because the statement itself should return true or false. -
@d-healey said in Just wondering about how this logic condition evaluates:
@VirtualVirgin said in Just wondering about how this logic condition evaluates:
Yes! That is the solution :)
You can probably also get rid of the ternary operator at the end -
? true : false
because the statement itself should return true or false.Yes, that makes sense. It is just evaluating to that anyway, so no need to make it redundant.