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

问题描述 投票:-1回答:1

这是我试图实现的目标:

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]

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

swift core-location
1个回答
2
投票

分隔符也必须是一个数组:

let cc = [aa, bb].joined(separator: [zero])
print(Array(cc))
© www.soinside.com 2019 - 2024. All rights reserved.