Stay organized with collections
Save and categorize content based on your preferences.
blockly > VariableMap > getVariable
VariableMap.getVariable() method
Find the variable by the given name and type and return it. Return null if it is not found.
Signature:
getVariable(name: string, opt_type?: string | null): VariableModel | null;
Parameters
Parameter |
Type |
Description |
name |
string |
The name to check for. |
opt_type |
string | null |
(Optional) The type of the variable. If not provided it defaults to the empty string, which is a specific type. |
Returns:
VariableModel | null
The variable with the given name, or null if it was not found.
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."],[[["The `getVariable()` method searches for a variable within the VariableMap by its name and optionally by its type."],["If a matching variable is found, the method returns a `VariableModel` object representing that variable; otherwise, it returns `null`."],["The `name` parameter is mandatory and specifies the name of the variable to search for."],["The `opt_type` parameter is optional and specifies the type of the variable; if not provided, it defaults to the empty string, which represents a specific type in Blockly."]]],[]]