Effective ActionScript: variable testing
It’s a pretty usual ActionScript code excerpt:
if (variable == true){ doSomething(); }
as you can see, the variable value is being tested here against its true value, which is a totally redundant action. A much more convenient style would be:
if (variable){ doSomething(); }
What so nice about this solution, that it can check any variable types for valid values. Both following tests work identically :
var variable:Number = null;
if (variable){ doSomething(); }
var variable:String = undefined;
if (variable){ doSomething(); }
0 Comments
No comments yet.
RSS feed for comments on this post. TrackBack URI
Sorry, the comment form is closed at this time.