Conditional compilation can be used to select some definitions for compilation while ignoring others. This is done using #if
statements and is similar in spirit to preprocessor directives such as #ifdef
in C and C++.
Example
public const bool toCompile = false; /** * Conditional compile test. */ private class ComTest { /** * Constructor. */ public constructor() { } /** * Print something? */ #if (toCompile) { extend public void printSomething() { pln("A"); } } else { extend public void printSomething() { pln("B"); } } } { ComTest test(); test.printSomething; }
Output:
B
Comments
0 comments
Please sign in to leave a comment.