blockly > CodeGenerator > addLoopTrap
CodeGenerator.addLoopTrap() method
Add an infinite loop trap to the contents of a loop. Add statement suffix at the start of the loop block (right after the loop statement executes), and a statement prefix to the end of the loop block (right before the loop statement executes).
Signature:
addLoopTrap(branch: string, block: Block): string;
Parameters
Parameter | Type | Description |
---|---|---|
branch | string | Code for loop contents. |
block | Block | Enclosing block. |
Returns:
string
Loop contents, with infinite loop trap added.