調査アンケート: Blockly のご利用体験についてお聞かせください
アンケートを開始
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
blockly > ワークスペース > createVariable
Workspace.createVariable() メソッド
v12: Blockly.Workspace.getVariableMap().createVariable を使用。
指定された名前、オプションの型、オプションの ID を持つ変数を作成します。
署名:
createVariable(name: string, opt_type?: string | null, opt_id?: string | null): IVariableModel<IVariableState>;
パラメータ
パラメータ |
型 |
説明 |
name |
文字列 |
変数名。これは、変数とプロシージャ間で一意である必要があります。 |
opt_type |
string | null |
(省略可)変数の型(int、string など)。一意である必要はありません。Field_variable は、変数の型に基づいて変数をフィルタできます。デフォルトでは、特定のタイプである「''」になります。 |
opt_id |
string | null |
(省略可)変数の一意の ID。デフォルトは UUID です。 |
戻り値:
IVariableModel<IVariableState>
新しく作成された変数。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-05-16 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-05-16 UTC。"],[[["The `createVariable()` method creates a new variable within the Blockly Workspace with a specified name, optional type, and ID."],["Variable names must be unique, while types can be shared and are used for filtering; IDs are auto-generated if not provided."],["The method returns a `VariableModel` object representing the newly created variable, allowing further manipulation."]]],[]]