MakeSlice examines the key type from the Array and create a slice with builtin type if possible. The idea is to avoid generating []any and produce more precise types.
(s []any)
| 434 | // builtin type if possible. The idea is to avoid generating []any and |
| 435 | // produce more precise types. |
| 436 | func (a *Array) MakeSlice(s []any) any { |
| 437 | slice := reflect.MakeSlice(toReflectType(a), 0, len(s)) |
| 438 | for _, item := range s { |
| 439 | slice = reflect.Append(slice, reflect.ValueOf(item)) |
| 440 | } |
| 441 | return slice.Interface() |
| 442 | } |
| 443 | |
| 444 | // ToSlice converts an ArrayVal into a slice. |
| 445 | func (a ArrayVal) ToSlice() []any { |
no test coverage detected