There isn't really any Swifty solution to do this per se. In an ideal world, you would be able to make a function return a tuple with arity equal to the fixed size of the array. Unfortunately, there are a number of barriers to this actually becoming a reality and I don't expect there to be any way to do something even remotely similar to this any time in the near future. A lot of these barriers are rooted in missing features in Swift's generics system. The two main ones AFAIK are:
- Lack of generic value parameters
- Because of this, you could not have the size of a length of a fixed-length array be statically known to the compiler as if it were on the same level as generic type parameter and so cannot return a tuple with the corresponding arity accordingly.
- Lack of variadic generics
- As of now the arity of every function, tuple, etc. that you declare must be explicitly declared. Because of this, one function cannot return tuples of different arities and furthermore cannot change the arity of their return type based on their input.
To my knowledge, those are the two main things that are preventing you from doing that. Hopefully we will see some of these features in Swift in the future though !
I just realized that your question says an array of known fixed size... . Well to answer that, no, there is no way to do that right now other than the monotonous manual method and AFAIK, there are not any plans to add something like this to Swift in the near future.