javascript array.splice(index, howmany, item1, ....., itemX)
index Required. The position to add/remove items. Negative value defines the position from the end of the array.
howmany Optional. Number of items to be removed.
item1, ..., itemX Optional. New elements(s) to be added.
Now, I want to get this same functionality in Powershell:
function splice {
param(
[string[]]$Array,
[int32]$Index,
[int32]$HowMany,
[string[]]$Item
)
}
$lines = @(
"abc",
"xyz"
"123"
)
$lines = splice -Array $lines -Index 1 -HowMany 0 -Item "foo", "bar"
Maybe there's a better way?