Swift array of generics

Viewed 3928

How do I create an array of generics? Example:

struct Thing<Any> {
}

let intThing = Thing<Int>()
let stringThing = Thing<String>()

// This line doesn't compile
// Cannot convert value of type 'Thing<Int>' to expected type 'Thing'
let things: [Thing] = [intThing, stringThing]

How do I declare a generic of any type (something like Thing<?> or Thing<Any>)?

4 Answers
Related