Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
blockly > VariableMap > getVariable
Méthode VariableMap.getVariable()
Recherchez la variable par nom et type donnés, puis renvoyez-la. Renvoie la valeur "null" si l'élément n'est pas trouvé.
Signature :
getVariable(name: string, opt_type?: string): IVariableModel<IVariableState> | null;
Paramètres
Paramètre |
Type |
Description |
nom |
chaîne |
Nom à rechercher. |
opt_type |
chaîne |
(Facultatif) Type de la variable. Si ce paramètre n'est pas fourni, la valeur par défaut est la chaîne vide, qui est un type spécifique. |
Renvoie :
IVariableModel<IVariableState> | null
Variable portant le nom donné, ou valeur nulle si elle n'a pas été trouvée.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/07/25 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Il n'y a pas l'information dont j'ai besoin","missingTheInformationINeed","thumb-down"],["Trop compliqué/Trop d'étapes","tooComplicatedTooManySteps","thumb-down"],["Obsolète","outOfDate","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Mauvais exemple/Erreur de code","samplesCodeIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/07/25 (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."]]],[]]