Skip to main content

blockly > Workspace > getVariable

Workspace.getVariable() method

Warning: This API is now obsolete.

v12: use Blockly.Workspace.getVariableMap().getVariable.

Find the variable by the given name and return it. Return null if 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.