subscript
Description
x1[x2] : x3
If x1 is a string, x1[x2] produces a one-character string consisting of character x2 of x1. x1[x2] produces a variable if x1 is a variable.
If x1 is a list or record, x1[x2] produces element x2 of x1.
If x1 is a table, x1[x2] produces the element corresponding to key x2 of x1.
In all cases, x2 may be nonpositive.
In all cases, the subscripting operation fails if the subscript is out of range.
Parameters
- x1
- string, list, table or record
- x2
- string for table or record. integer for string or list
- returns
- element or fail
Errors
101 |
x1 is string, list, or a record, but x2 not integer |
114 |
x1 not string, list, table, or record |
See Also
- x[x, …] — multiple subscript
- x[i:i] — produce substring or list section