2009-08-06 42 views
1
 
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 =? 

回答

1

由于任务在ActionScript中的值,这使得该语法合法的,他们没有在Java中的值,这使得它不。不同之处在于,尽管最近出现了Java化,Actionscript也是来自ECMAScript。这种设计的其他后果的发言这样的能力:

var foo:Number = 0; 
var bar:Number = 0; 
foo = bar = 2; 
assertEquals(2, foo); 
assertEquals(2, bar); 

IMO,这是它能够有最好的表现 - 它不会破坏与旧版本的ActionScript的相容性,它不会删除语言功能的目的是手持,但它确实给用户的注意力带来了一个常见的错误。

0

我的猜测是编译器可能会自动修复它?

虽然Flex会这么做很有趣。

(并顺便说一句,这不是“软硬”,它的ActionScript 3)