例如:
- var a = [1,2,3] // Ints
- var s = ",".join(a) // EXC_BAD_ACCESS
尝试这个
- var a = [1,".join(a.map { $0.description })
- extension String {
- func join<S : SequenceType where S.Generator.Element : Printable>(elements: S) -> String {
- return self.join(map(elements){ $0.description })
- }
- // use this if you don't want it constrain to Printable
- //func join<S : SequenceType>(elements: S) -> String {
- // return self.join(map(elements){ "\($0)" })
- //}
- }
- var a = [1,".join(a) // works with new overload of join
连接被定义为@H_404_4@
- extension String {
- func join<S : SequenceType where String == String>(elements: S) -> String
- }
这意味着它需要一个字符串序列,你不能传递一个int序列.@H_404_4@