uk.co.badgersinfoil.metaas
Interface ASIfStatement

All Superinterfaces:
StatementContainer

public interface ASIfStatement
extends StatementContainer

Obtained from StatementContainer.newIf(String), an ASIfStatement allows statements to be added to the 'then' and else' branches.

e.g. To simply add statements to the 'then' branch (executed when the condition holds true),

 ASIfStatement ifStmt = method.newIf("test()");
 isStmt.addStmt("trace('test succeeded')");
 

will result in ActionScript code like,

 if (test()) {
 	trace('test succeeded');
 }
 

To add code to both 'then' and 'else' branches,

 ASIfStatement ifStmt = method.newIf("test()");
 isStmt.addStmt("trace('test succeeded')");
 ifStmt.getElse().addStmt("trace('test failed')");
 

will result in ActionScript code like,

 if (test()) {
 	trace('test succeeded');
 } else {
 	trace('test failed');
 }
 

Note that the first call to getElse() will cause the else-block to be created (even if no statements are subsequently added to it). Subsequent calls to getElse() will return references to the same else-block.


Method Summary
 StatementContainer getElse()
          Returns a reference to an object which can populate the else-clause of this ActionScript if-statement with new code.
 
Methods inherited from interface uk.co.badgersinfoil.metaas.StatementContainer
addComment, addStmt, newDoWhile, newFor, newForIn, newIf, newSwitch, newWhile
 

Method Detail

getElse

public StatementContainer getElse()
Returns a reference to an object which can populate the else-clause of this ActionScript if-statement with new code.