Skip to: Site menu | Main content

Blog...

Boolean() vs "as Boolean"

I came across an interesting quirk in Flex today.

I was trying to convert the string "false" to a boolean false. Initially I had this code:


var str:String = "false";
var isDefault:Boolean = Boolean(str);

isDefault always had a value of true. According to the Flex documenation any non empty string value is considered true.

This works as expected:


var str:String = "false";
var isDefault:Boolean = str as Boolean;

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001.