Stay organized with collections
Save and categorize content based on your preferences.
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.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThis method redraws any attached marker or cursor SVGs to the BlockSvg if they require updating.\u003c/p\u003e\n"],["\u003cp\u003eIt's a protected method within the BlockSvg class, meaning it's primarily for internal use within Blockly's functionality.\u003c/p\u003e\n"],["\u003cp\u003eThe method doesn't return any specific value (void), simply performing the update action when invoked.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [CodeGenerator](./blockly.codegenerator_class.md) \\\u003e [addLoopTrap](./blockly.codegenerator_class.addlooptrap_1_method.md)\n\nCodeGenerator.addLoopTrap() method\n\nAdd 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).\n\n**Signature:** \n\n addLoopTrap(branch: string, block: Block): string;\n\nParameters\n\n| Parameter | Type | Description |\n|-----------|-----------------------------------|-------------------------|\n| branch | string | Code for loop contents. |\n| block | [Block](./blockly.block_class.md) | Enclosing block. |\n\n**Returns:**\n\nstring\n\nLoop contents, with infinite loop trap added."]]