In my application I want to create an generic method which creates an array of object depening on the given type T.
I created the following function:
fun
I worked around this by borrowing from the swift runtime function unsafeBitCast.
It's declared as func unsafeBitCast and you can call it as unsafeBitCast(value, MyType).
Applied to your function this would be
func getArray(key:String, _: T.Type) -> T[] {
// function stays the same
}
And you can call it like this
getArray("key", Document)