- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.

Name | ### splice()
Examples |
    String[] a = { "OH", "NY", "CA" };
    a = splice(a, "KY", 1);  // Splice one value into an array
    println(a);
    // Prints the following array contents to the console:
    // [0] "OH"
    // [1] "KY"
    // [2] "NY"
    // [3] "CA"

    println();  // Prints a blank line

    String[] b = { "VA", "CO", "IL" };
    a = splice(a, b, 2);  // Splice one array of values into another
    println(a);
    // Prints the following array contents to the console:
    // [0] "OH"
    // [1] "KY"
    // [2] "VA"
    // [3] "CO"
    // [4] "IL"
    // [5] "NY"
    // [6] "CA"
Description | Inserts a value or an array of values into an existing array. The first two parameters must be arrays of the same datatype. The first parameter specifies the initial array to be modified, and the second parameter defines the data to be inserted. The third parameter is an index value which specifies the array position from which to insert data. (Remember that array index numbering starts at zero, so the first position is 0, the second position is 1, and so on.) When splicing an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index)
Syntax |
    splice(list, value, index)
Parameters |
list | Object, String[], float[], int[], char[], byte[], or boolean[]: array to splice into
value | Object, String[], String, float[], float, int[], int, char[], char, byte[], byte, boolean[], or boolean: value to be spliced in
index | int: position in the array from which to insert data
Returns | boolean[], byte[], char[], int[], float[], String[], or Object
Related | concat() subset()

Updated on January 9, 2020 00:33:09pm EST