开发者

Testing Boolean in Actionscript for null

开发者 https://www.devze.com 2023-03-10 09:06 出处:网络
I have a Boolean variable in Actionscript 3. How can I check if it\'s undefined (not by being false) because false is a value or Boolean in Actionscript is FALSE 开发者_如何学Pythonby default >If you

I have a Boolean variable in Actionscript 3.

How can I check if it's undefined (not by being false) because false is a value or Boolean in Actionscript is FALSE 开发者_如何学Pythonby default >


If you want a Boolean that can be undefined (essentially a tri-state flag), you can use an Object reference, but just assign the Boolean values true and false to it. Downside is that you lose the type safety.

var isSet:Object = null;
// Later...
isSet = true;


In ActionScript, Boolean can have either true or false value only. If you don't specify any value, it is initialized to false by default.

Edit: This behavior is different from Java's Boolean object type which is a wrapper over primitive boolean. See @Victor's comments below

0

精彩评论

暂无评论...
验证码 换一张
取 消