rewrite expand
This commit is contained in:
parent
8d509bf71a
commit
8b8ab675bd
|
@ -37,8 +37,14 @@ type about struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func expand(arr []any, idx int) []any {
|
func expand(arr []any, idx int) []any {
|
||||||
front := append(arr[:idx], nil)
|
var all []any
|
||||||
all := append(front, arr[idx:])
|
if idx < len(arr) {
|
||||||
|
all = arr
|
||||||
|
} else {
|
||||||
|
all = make([]any, idx+1)
|
||||||
|
copy(all[:len(arr)], arr)
|
||||||
|
all[idx] = make(map[string]any)
|
||||||
|
}
|
||||||
return all
|
return all
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue