Skip to main content

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): IVariableModel<IVariableState> | null;

Parameters

Parameter

Type

Description

name

string

The name to check for.

opt_type

string

(Optional) The type of the variable. If not provided it defaults to the empty string, which is a specific type.

Returns:

IVariableModel<IVariableState> | null

The variable with the given name, or null if it was not found.