[swift-evolution] Rename joinWithSeparator() to join() and make it work with all classes.
Sebastian Mecklenburg
mecklenburg at rechenmaschinist.de
Fri Dec 25 01:49:11 CST 2015
Hello group,
This is my first post here so please tell me if I’m doing something wrong.
The function name joinWithSeparator() sounds like an ObjectiveCism to me. Why not just name it join()? I is a common function found in many libraries of other programming languages and it is always simply called join(). I don’t think there is much room for misunderstanding what the parameter does.
Also, why is it limited to String only SequenceTypes? An implementation like
extension SequenceType {
func join(separator: String) -> String {
let arr = self.map({String($0)})
return arr.joinWithSeparator(separator)
}
}
would work fine with all classes that implement the CustomStringConvertible protocol and, for classes that don’t, the worst thing that would happen is that it would generate a string of repeating class names.
What do you think?
Thanks and regards,
Sebastian Mecklenburg
More information about the swift-evolution
mailing list