One often wants to place separators between substrings.
For instance commas between a list of words.
The code has to detect whether it is adding the last element to avoid adding a final comma.
It would simpler if you could subtract a string at the end.
(- “, “) + “, a, b, c, d” = “a, b, c, d”
“a, b, c, d, ” - “, ” = “a, b, c, d”