3 ms·
There are conventions that help, but they could be made explicit: - If you don't know where a slice came from (such as getting it passed as an argument), treat
by skybrian 5y ago
There are conventions that help, but they could be made explicit:
- If you don't know where a slice came from (such as getting it passed as an argument), treat it as read-only. Any exceptions should be documented.
- If you're going to mutate a slice, make it a private member of a struct and don't give out direct access to it.