Elements returns an array of Values for the given container type. Returns an error if the element is not an array or set.
()
| 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. |
| 202 | func (v Value) Elements() ([]Value, error) { |
| 203 | innerType := InnerType(v.Type()) |
| 204 | if innerType == nil { |
| 205 | return nil, ErrNotContainer |
| 206 | } |
| 207 | var elements []Value |
| 208 | for it := v.ContainerIter(); !it.Done(); { |
| 209 | elements = append(elements, NewValue(innerType, it.Next())) |
| 210 | } |
| 211 | return elements, nil |
| 212 | } |
| 213 | |
| 214 | func (v Value) ContainerLength() (int, error) { |
| 215 | switch v.Type().(type) { |