array-access.txt 344 B

1234567891011121314
  1. case []{1}:
  2. a := object.([]{1})
  3. if isSet {
  4. a[index] = value.({1})
  5. } else {
  6. if index >= len(a) {
  7. if panics {
  8. panic(fmt.Sprintf("objx: Index %d is out of range because the []{1} only contains %d items.", index, len(a)))
  9. }
  10. return nil
  11. } else {
  12. return a[index]
  13. }
  14. }