I'll give it a try:
`b[0..^1]` is equivalent to `b[0..b.len-1]`
where ^1 is a "shortcut" that makes it easy to get the last element.
Because the string ends in a period (`b = "Slices are useless."`) then to get
the portion of the string that is "useless" and replace it with "useful",
remembering that indices are zero based,
"Slices are useless."
| | |
0 11 17 using indices
^19 ^8 ^2 using ^ syntax
then
`b[11..^2]` is the portion "useless" and
`b[11..^2] = "useful"` replaces the "useless" portion with "useful"
and hence
`echo b` displays `Slices are useful.`
Note: you could also do it as `b[^8..^2] = "useful"` or as `b[11..b.len-2] =
"useful"` or as `b[11..<b.len-1] = "useful"` or as `b[^8..^2] = "useful"` or as
....