Many programming languages, including Python, support an operation like this:
", ".join(["1","2","3"])
which returns the string
"1, 2, 3"
I understand that this is the case, but I don't understand the design decision behind it - surely it would be more semantically valid to perform the join
operation on the list, like so:
["1","2","3"].join(", ")
If anyone could explain the design decision and shed some light on it I'd appreciate it.
Edit: It looks like Javascript has the join
method on the list; if anyone has examples for which convention particular languages follow, feel free to comment/answer about the choice in that particular language too.