protocol Test{ var t: Int {set get} } struct A: Test{ var t: Int } struct B: Test{ var t: Int var s: String } let a = A(t: 1) let b = B(t: 2
You cannot convert an array wholesale like that. Use map:
map
let f = e.map { $0 as Test } // f is now a [Test] array