Joe runs the new method template and is pleased with the result. There is only one problem: if the return type is "void", Joe would rather not have the two lines where the return variable is initialized and returned. To fix this, Joe changes the template to the following:
#prompt ( "Method Description:" $methodDescription ) #prompt ( "Return Type:" $returnType "void") #prompt ( "Method Name:" $methodName ) #prompt ( "Parameters:" $parameters ) /** * ${methodDescription} */ public ${returnType} ${methodName}(${parameters}) { #if ( $returnType != "void" ) ${returnType} retVal = null; return retVal; #end }
Note the addition of the #if/#end
block around the
two lines in question. Now when Joe runs the template, the method body
will be empty if the return type is "void".