SetSliceIndex sets the value at the specified index in the slice.
(i int, val *Value)
| 91 | |
| 92 | // SetSliceIndex sets the value at the specified index in the slice. |
| 93 | func (v *Value) SetSliceIndex(i int, val *Value) error { |
| 94 | unpacked := v.UnpackKinds(reflect.Interface, reflect.Pointer) |
| 95 | if !unpacked.isSlice() { |
| 96 | return ErrUnexpectedType{ |
| 97 | Expected: TypeSlice, |
| 98 | Actual: v.Type(), |
| 99 | } |
| 100 | } |
| 101 | if i < 0 || i >= unpacked.value.Len() { |
| 102 | return SliceIndexOutOfRange{Index: i} |
| 103 | } |
| 104 | unpacked.value.Index(i).Set(reflect.ValueOf(val)) |
| 105 | return nil |
| 106 | } |
| 107 | |
| 108 | // RangeSlice iterates over each item in the slice and calls the provided function. |
| 109 | func (v *Value) RangeSlice(f func(int, *Value) error) error { |