研究调查问卷:请告诉我们您使用 Blockly 的体验
开始调查问卷
blockly >VariableMap >getVariable
VariableMap.getVariable() 方法
按指定名称查找变量,然后返回该变量。如果未找到,则返回 null。
Signature:
getVariable(name: string, opt_type?: string | null): VariableModel | null;
参数
参数 |
类型 |
说明 |
name |
字符串 |
要检查的名称。 |
opt_type |
字符串 |null |
(可选)变量的类型。如果未提供,则默认为空字符串,这是一种特定类型。 |
返回:
VariableModel |null
具有指定名称的变量;如果未找到,则为 null。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2024-08-22。
[null,null,["最后更新时间 (UTC):2024-08-22。"],[[["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."]]],[]]