3 ms·
This needs a 2001 tag, particular since it is no longer the case as others have pointed out.
by pimlottc 12y ago
This needs a 2001 tag, particular since it is no longer the case as others have pointed out.
- masklinn 12y agoIt is probably the case in other languages though (I believe — though I'm open to being wrong — it is in Go, string slicing is implemented through array slicing, so a substring will share the parent string's storage and keep it alive).
- deleted 12y ago[deleted]
- masklinn 12y ago> substrings are mutable Are you sure? I know that a byte slice []byte is mutable, but I thought slicing a string yielded a string (and strings are immutable), an explicit conversion (and copy) is needed to get the underlying byte slice.
- pcwalton 12y agoOh yes, my mistake, they're immutable. I was thinking of []byte.