How to join array of array locations with zero location?

This is what I try to achieve:

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)

I need to have sth like this:

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

Argument passed to call that takes no arguments

1 answer

  • answered 2018-07-11 05:58 Sulthan

    The separator must be an array too:

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