如何以零位置连接数组位置的数组?

时间:2018-07-11 05:54:49

标签: swift core-location

这是我试图实现的目标:

let a = CLLocation(latitude: 10, longitude: 20)
let b = CLLocation(latitude: 10, longitude: 40)
let c = CLLocation(latitude: 10, longitude: 60)
let d = CLLocation(latitude: 10, longitude: 80)

let aa = [a, b]
let bb = [c, d]

let zero = CLLocation(latitude: 0, longitude: 0)

let cc = [aa, bb].joined(separator: zero)

我需要这样的东西:

let output = [a, b, zero, c, d]
  

传递给不带参数的调用的参数

1 个答案:

答案 0 :(得分:2)

分隔符也必须是数组:

let cc = [aa, bb].joined(separator: [zero])
print(Array(cc))