klyn.collections.ArrayList.add
method
public native add(index as Int, item as T) as Void
Description

Inserts an element at the requested index.

Existing elements at and after the index are shifted to the right. Passing size appends the element.

Parameters
ParameterDescription
indexZero-based insertion index in [0, size].
itemThe element to insert.
Throws
  • IndexException if index is outside [0, size].
Example
import klyn.collections

data = ["A", "C"]
data.add(1, "B")
print(data)  # [A, B, C]