Skip to content

Commit

Permalink
niknaks.arrays
Browse files Browse the repository at this point in the history
- New feature added
  • Loading branch information
deavmi committed May 10, 2024
1 parent da8ae74 commit 88d3208
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions source/niknaks/arrays.d
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,18 @@ unittest
assert(numbas == [1, 2]);
}



/**
* Inserts the given value into
* the array at the provided index
*
* Params:
* array = the array to insert
* into
* position = the position to
* insert at
* value = the value to insert
* Returns: the updated array
*/
public T[] insertAt(T)(T[] array, size_t position, T value)
{
if(position > array.length)
Expand Down Expand Up @@ -517,6 +527,10 @@ public T[] insertAt(T)(T[] array, size_t position, T value)
}
}

/**
* Tests inserting into an array
* at the given index
*/
unittest
{
int[] vals = [];
Expand Down

0 comments on commit 88d3208

Please sign in to comment.