Skip to content

Instantly share code, notes, and snippets.

@darscan
Created May 26, 2012 11:22
Show Gist options
  • Save darscan/2793564 to your computer and use it in GitHub Desktop.
Save darscan/2793564 to your computer and use it in GitHub Desktop.
AS3 Logical OR
// 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