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 {
|
||||
front := append(arr[:idx], nil)
|
||||
all := append(front, arr[idx:])
|
||||
var all []any
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue