Let's assume we have a custom type given by
struct S {
let value_1: UInt = 1
let value_2: UInt = 2
}
and I want to create a Double array (e.g. [1.0, 2.0]) using a cast:
let s = S()
let a = s as Array<Double> // fails obviously
The final goal is to call
func aMethod(array: [Double]) { ... }
in a convient way:
let s = S()
aMethod(s)
My first idea was to use
extension S {
// but how to continue here?
}
Any ideas of solving this in an elegant way without a static method?