zed
zed copied to clipboard
index & slice operators on bytes/strings
expr.Index() should be able to index a bytes type and return a uint8.
It should also be possible to index a string type and return a rune.
(The index operator already works on arrays.)
While we're at it, we can add a slice operator that works with bytes, strings, and arrays.
All the above should be made to work in ZQL.
Support for slicing in arrays was added in #2099. We'll circle back to add support for the other data types as use cases emerge that make them a priority.
Hmm, we have slices working but not simple indexing...
$ echo '"abc"' | zq 'yield this[0]' -
error("missing")
$ echo '"abc"' | zq 'yield this[0:1]' -
"a"
@nwt, this should be easy to address yes?