このページでは「P5.js 日本語リファレンス」 のcreateNumberDict 関数を説明します。
createNumberDict()
説明文
指定したキーと値のペアまたはオブジェクトを使用して p5.NumberDict の新しいオブジェクトを作成します。
構文
createNumberDict(key, value)
createNumberDict(object)
パラメタ
key
Number:キー名value
Number:値object
Object:オブジェクト
戻り値
p5.NumberDict:
例
function setup() {
// キー 100 に 42 を設定して、p5.NumberDict のオブジェクトを生成
let myDict = createNumberDict(100, 42);
// .hashkey() を使用してキー 100 の存在を確認します
// (存在するとき true をコンソールに表示)
// なお、.hashkey() は p5.TypedDict で定義されています
print(myDict.hasKey(100));
// キー 100 の値をコンソールに表示
// .get() は p5.TypedDict で定義されています
print(myDict.get(100));
}
実行結果
著作権
p5.js was created by Lauren McCarthy and is developed by a community of collaborators, with support from the Processing Foundation and NYU ITP. Identity and graphic design by Jerel Johnson.
ライセンス
Creative Commons(CC BY-NC-SA 4.0) に従います。