The Splice function

With the splice function we can delete and replace list elements in an array.

The splice function uses the following syntax:

splice ([array], [offset], [length], [list of new elements]);

The array argument is the array to be manipulated.
offset is the starting point where elements are to be removed.
length is the number of elements from the offset number to be removed.
The list argument is optional and consists of an ordered list of values to replace the removed elements with.

For example, the following code will modify the @numbers list array to include the elements, ("1" , "2", "three", "four", "5").

@numbers = ("1", "2", "3", "4", "5");
splice (@numbers, 2, 2, "three", "four");

A more common usage of the splice is simply to remove list elements by not specifying a replacement list.

For example, we might modify @numbers to include only the elements "1", "2" and "5" by using the following code:

splice (@numbers, 2, 2);

Exercise
Remove all the working days from your weeks array with splice and replace them with a 'holiday'