Using Array Elements
Using Array Elements
Now, the elements can be accessed by their indices (plural of index).
Examples:
Processing:
Adding Elements to an Array
Sometimes you need to add elements to an array. Often, you’ll get an error if you try to assign a value to a non-existent “slot” or reference an index outside of what is available.
Most languages use a function such as .append()
or .expand()
or .push()
or .add()
Examples:
Processing:
Removing Elements from an Array
Making an index / element empty does not remove the element.
To remove the element, use a function such as .shorten()
(Processing) or .Remove()
(Unity/C#).
Examples:
Processing:
Sorting Arrays
To sort an array, use a function such as .sort()
for alphabetical OR .reverse()
for the opposite.
Examples:
Processing:
Last updated