[Pitch] Rename flatten() to joined() and give joined() for string sequences the empty string as the default parameter


(Tim Vermeulen) #1

Currently

someSequence.joined(separator: [])
someSequence.flatten()

(where someSequence is a sequence of sequences) results in two equal sequences (apart from their exact types). I would like to have flatten() renamed to joined(), resulting in joined(_:slight_smile: seemingly having an empty array as the default parameter.

Similarly, I propose to give joined(_:slight_smile: for a sequence of strings the empty string as the default parameter, allowing us to replace something like

["Hello, ", "world!"].joined(separator: "") // "Hello, world!"

with

["Hello, ", "world!"].joined() // "Hello, world!”

In other words, I think joined(_:slight_smile: should have a default parameter of either `[]` or `””` and flatten() could then be removed as it would act the exact same way as joined().