Buffer[ ]
Buffer indexing allow to get/set individual byte value.
- The index value must be an integer.
- First byte of the Buffer starts at index 1.
- Negative index means counting from the end of the Buffer (for example buffer[-1] means the last byte)
Example
local buff = sys.Buffer { 97, 98, 99 } -- a, b, c in UTF8
-- change last byte of the buffer
buff[-1] = 67
-- outputs "abC"
print(buff)
-- outputs 67
print(buff[-1])