Skip to main content

Vector.insert

insertatitem

Group: Calculations

Documentation

Inserts the given item into the vector at the given index.

Arguments

  • at: The index at which to insert the item before. If the index is less than 0, the index will be counted back from the end. If the index is equal to the length of the vector, the item will be appended to the end of the vector.
  • item: The item to insert into the vector.

Examples

Insert 'X' into a vector at different locations:

     ['a', 'b', 'c'].insert 1 'X' == ['a', 'X', 'b', 'c']
['a', 'b', 'c'].insert -1 'X' == ['a', 'b', 'X', 'c']
['a', 'b', 'c'].insert item='X' == ['a', 'b', 'c', 'X']