diff options
author | NeonXP <i@neonxp.dev> | 2022-11-16 21:35:48 +0300 |
---|---|---|
committer | NeonXP <i@neonxp.dev> | 2022-11-16 21:35:48 +0300 |
commit | eb26d597c6d526f84077afdc141b0a5d585c7da3 (patch) | |
tree | a07e5e4c79e3217afb87877287315bb8590b989f /model/array.go | |
parent | c730afe0f889587630789c4fa38267d1edf465f2 (diff) |
Utility methodsv0.0.1
Diffstat (limited to 'model/array.go')
-rw-r--r-- | model/array.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/model/array.go b/model/array.go index b3d2586..5d64209 100644 --- a/model/array.go +++ b/model/array.go @@ -30,3 +30,13 @@ func (n *Node) Each(cb func(idx int, value *Node) error) error { } return nil } + +// RemoveIndex from array +func (n *Node) RemoveIndex(idx int) error { + arrlen := len(n.arrayValue) + if idx >= arrlen { + return fmt.Errorf("index %d out of range (len=%d)", idx, arrlen) + } + n.arrayValue = append(n.arrayValue[:idx], n.arrayValue[idx:]...) + return nil +} |