Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion builtins.go
Original file line number Diff line number Diff line change
Expand Up @@ -2485,6 +2485,7 @@ func builtinRemove(i *interpreter, arrv value, ev value) (value, error) {
}

func builtinRemoveAt(i *interpreter, arrv value, idxv value) (value, error) {
var newArr []*cachedThunk
arr, err := i.getArray(arrv)
if err != nil {
return nil, err
Expand All @@ -2494,7 +2495,8 @@ func builtinRemoveAt(i *interpreter, arrv value, idxv value) (value, error) {
return nil, err
}

newArr := append(arr.elements[:idx], arr.elements[idx+1:]...)
newArr = append(newArr, arr.elements[:idx]...)
newArr = append(newArr, arr.elements[idx+1:]...)
return makeValueArray(newArr), nil
}

Expand Down
7 changes: 7 additions & 0 deletions testdata/builtinRemoveAt2.golden
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[
"quux",
"foo",
"bar",
"foo",
"bar"
]
3 changes: 3 additions & 0 deletions testdata/builtinRemoveAt2.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
local a = ['quux','foo','bar'];
local b = std.removeAt(a,0);
a+b
Empty file.