Re: [flexcoders] ObjectUtil.compare seems a little incorrect for Boolean values
>From the help for the as operator (search for operators):Returns the first operand if it is a member of the data type specified by the second operand.The important bit is if it is a member.Number(a) will give you 1 and 0 though. I'm not sure if this is going to help you much for your specific problem with compare though. I would almost say that it was a bug... -- davidMay the forces of evil become confused on the way to your house. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[flexcoders] ObjectUtil.compare seems a little incorrect for Boolean values
I am working to override a sortCompareFunction on a column, and in doins so, I am handling my specific case and when applicable, just passing to ObjectUtil.compare() so as not to reimplement all of the simple type checking. One case that I have is when the comparison objects are Booleans. Looking at the source, it looks like it takes the Booleans and performs a numericCompare on them. Makes sense to me.. assuming that true maps to 1 and false maps to 0. However, strangely enough, they BOTH map to 0. I know I can handle this myself in my own code, but doesn't this seem like a bug? Very simply, execute this: code var a:Boolean = true; var b:Boolean = false; var aNum:Number = a as Number; var bNum:Number = b as Number; Alert.show(Boolean: + a + , + b + ; Number: + aNum + , + bNum); //var comparison:int = ObjectUtil.compare(a, b); // the result here is always 0; /code What would you expect the result to be? Personally, I would have expected: Boolean: true, false; Number: 1, 0 Perhaps I am just getting loopy/tired in figuring this out. Thanks for any feedback. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
[flexcoders] ObjectUtil.compare seems a little incorrect for Boolean values
I am working to override a sortCompareFunction on a column, and in doins so, I am handling my specific case and when applicable, just passing to ObjectUtil.compare() so as not to reimplement all of the simple type checking. One case that I have is when the comparison objects are Booleans. Looking at the source, it looks like it takes the Booleans and performs a numericCompare on them. Makes sense to me.. assuming that true maps to 1 and false maps to 0. However, strangely enough, they BOTH map to 0. I know I can handle this myself in my own code, but doesn't this seem like a bug? Very simply, execute this: code var a:Boolean = true; var b:Boolean = false; var aNum:Number = a as Number; var bNum:Number = b as Number; Alert.show(Boolean: + a + , + b + ; Number: + aNum + , + bNum); //var comparison:int = ObjectUtil.compare(a, b); // the result here is always 0; /code What would you expect the result to be? Personally, I would have expected: Boolean: true, false; Number: 1, 0 Perhaps I am just getting loopy/tired in figuring this out. Thanks for any feedback. -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Web site design development Computer software development Software design and development Macromedia flex Software development best practice YAHOO! GROUPS LINKS Visit your group "flexcoders" on the web. To unsubscribe from this group, send an email to:[EMAIL PROTECTED] Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.