Hey everyone,
I'm not sure why this is not working, and i'd like to understand why I get
the compile error. I just keep looking at the code and thinking it should
be okay. I'm basically trying to set a Boolean via a "inline check". Here
are some variables to give you an idea of the initialized state.
var str1:String = "";
var num1:Number;
var num2:Number = 0;
var resultBool:Boolean = false;
Here's the line of code.
resultBool = (str1 != "" | (!isNaN(num1) | num2 != 0));
It looks more confusing when I removed the context out of it, but yeah
that's it.
When I compile it I get the follow error:
1067: Implicit coercion of a value of type Boolean to an unrelated type
Number.
I ultimately expanded the logic to be this, to stop the compile error from
happening.
if(str1 != "")
resultBool = true;
else{
if(!isNaN(num1))
resultBool = true;
else if(num2 != 0)
resultBool = true;
}
I even tried this variation and still got the exception during compile.
resultBool = (str1 != "") | (!isNaN(num1) | num2 != 0);
So yeah. I'm certainly not adverse to having the expanded version in my
code. It will probably be easier to read anyways. I just wanna get my
head straight on understanding the why.
Thanks in advance,
Chris