If I use an Assignment within conditional, for e.g. if(userType='admin') Flex throws a warning,unlike Java, which throws an error. Why should Flex be doing this, despite being one of the newest languages? 1100: Assignment within conditional. Did you mean == instead of =?
views:
136answers:
2
A:
My guess is that the compiler probably automatically fixes it?
It is interesting though that Flex would do that.
(and btw, it's not "Flex", it's Actionscript 3)
Jage
2009-08-06 15:00:40
+1
A:
Because assignments have a value in Actionscript, which makes that syntax legal, and they don't have a value in Java, which makes it not. The difference comes because despite recent Java-izations, Actionscript is descended from ECMAScript. Other consequences of this design are the ability to make statements like this:
var foo:Number = 0;
var bar:Number = 0;
foo = bar = 2;
assertEquals(2, foo);
assertEquals(2, bar);
IMO, this is the best behavior it could have - it doesn't break compatibility with older versions of Actionscript, and it doesn't remove language functionality for the purpose of handholding, but it does bring a common error to the attention of the user.
Dan Monego
2009-08-06 15:29:28