Created
May 26, 2012 11:22
-
-
Save darscan/2793564 to your computer and use it in GitHub Desktop.
AS3 Logical OR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In AS3 | |
a ||= value; | |
// is shorthand for: | |
if (a == false) { // 1: Tests truthiness, not strict null | |
a = value; | |
} else { | |
a = a; // 2: Will reassign | |
} | |
// 2 is important to understand as it impacts setters with side-effects (obviously not a good idea, but still). | |
// It's a pity that it works this way. Many other languages actually short-circuit - which is much more desirable. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment