If the passed-in element is an array, attempt to get the idx'th element, and return its type and raw representation. Returns an error if the passed-in element is not an array or if idx is outside the array bounds.
(idx int64)
| 181 | // error if the passed-in element is not an array or if idx is |
| 182 | // outside the array bounds. |
| 183 | func (v Value) ArrayIndex(idx int64) (Value, error) { |
| 184 | vec, ok := v.Type().(*TypeArray) |
| 185 | if !ok { |
| 186 | return Null, ErrNotArray |
| 187 | } |
| 188 | if idx < 0 { |
| 189 | return Null, ErrIndex |
| 190 | } |
| 191 | for i, it := 0, v.ContainerIter(); !it.Done(); i++ { |
| 192 | bytes := it.Next() |
| 193 | if i == int(idx) { |
| 194 | return NewValue(vec.Type, bytes), nil |
| 195 | } |
| 196 | } |
| 197 | return Null, ErrIndex |
| 198 | } |
| 199 | |
| 200 | // Elements returns an array of Values for the given container type. |
| 201 | // Returns an error if the element is not an array or set. |
nothing calls this directly
no test coverage detected