I'm perusing the short tutorial and the docs, but can't find anything about indexing or slicing these?
Hi @Alper,
What would you like to know about indexing and slicing (of strings, lists or something else?) ?
I can help you out and update the docs :)
Maybe these are what you are looking for?
https://www.roc-lang.org/docs/main/List/#sublist
https://www.roc-lang.org/docs/main/Str/#split_first
Like I can't figure out if list methods should work on Str?
And I found those functions but it seems there isn't a []?
we currently don't have a foo[bar] syntax
we've talked about it in the past, but it honestly doesn't seem like there's been much demand for it :smile:
Alper said:
Like I can't figure out if list methods should work on Str?
List and Str have totally separate methods; Str doesn't have any formal relationship to List
you can convert a Str to a list of bytes with Str.to_utf8. If you want to split a Str into graphemes, you can use Grapheme.split from the unicode package.
Richard Feldman said:
we've talked about it in the past, but it honestly doesn't seem like there's been much demand for it :smile:
Oh yeah, I'm sure it could be a nightmare to even agree on what it should do or how it should work.
Last updated: Sep 03 2026 at 15:16 UTC