Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
blockly > Zablokuj > renameVarById
Metoda Block.renameVarById()
Powiadomienie o zmianie nazwy zmiennej. Jeśli identyfikator pasuje do jednej ze zmiennych tego bloku, zmień jego nazwę.
Podpis:
renameVarById(oldId: string, newId: string): void;
Parametry
Parametr |
Typ |
Opis |
oldId |
ciąg znaków |
Identyfikator zmiennej, której nazwę chcesz zmienić. |
newId |
ciąg znaków |
Identyfikator nowej zmiennej. Może być taki sam jak oldId, ale ma nową nazwę. |
Zwroty:
nieważne
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-25 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 2025-07-25 UTC."],[],["The `renameVarById` method within the `Block` class handles variable renaming. It checks if a provided `oldId` matches any of the block's variable IDs. If a match is found, the variable's ID is updated to the provided `newId`. The method takes two string parameters: `oldId` (the original ID) and `newId` (the updated ID) and does not return any value. This method ensures variable consistency across the block during a rename operation.\n"]]