Skip to main content

Home > 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

ParameterTypeDescription
branchstringCode for loop contents.
blockBlockEnclosing block.

Returns:

string

Loop contents, with infinite loop trap added.