The chained(with:)
method concatenates the elements of two sequences.
An example from the documentation is:
let numbers = [10, 20, 30].chained(with: 1...5)
// Array(numbers) == [10, 20, 30, 1, 2, 3, 4, 5]
In my opinion, that does not read well at the point of use, and I think a clearer name can be found.
Swift already uses append(contentsOf:)
for a mutating method on RangeReplaceableCollection
, so I think it would be most consistent to name this one appending
.
Personally, I’d say a name like followed(by:)
, would be even clearer, as in:
let numbers = [10, 20, 30].followed(by: 1...5)
// Array(numbers) == [10, 20, 30, 1, 2, 3, 4, 5]
But either way, chained(with:)
is neither clear nor consistent.