0
0

More than 3 years have passed since last update.

P5.js 日本語リファレンス(splice)

Last updated at Posted at 2020-05-24

このページでは「P5.js 日本語リファレンス」 の splice関数を説明します。

splice()

説明文

注意: 非推奨

splice() は非推奨であり、p5の将来のバージョンでは削除される予定です。代わりにarray.splice() を使用してください。

値または値の配列を既存の配列に挿入します。list パラメータは変更する初期配列を指定し、value パラメータは挿入するデータを定義します。 position パラメータは、データを挿入する配列の位置を指定するインデックス値です。 (配列のインデックス番号は0から始まるため、最初の位置は0、2番目の位置は1というように続きます)

構文

splice(list, value, position)

パラメタ

  • list

    Array:変更する配列

  • value

    Any:挿入する値

  • position

    Number:データを挿入する位置

戻り値

Array:リスト

例1

function setup() {
  let myArray = [0, 1, 2, 3, 4];
  let insArray = ['A',  'B',  'C​​'];
  print(myArray); // [0, 1, 2, 3, 4]
  print(insArray); // ['A',  'B',  'C​​']

  splice(myArray, insArray, 3);
  print(myArray); // [0, 1, 2, 'A', 'B', 'C​​', 3, 4]
}

著作権

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) に従います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0