'swift handle variable arguments of different template types
My actual problem is much more complicated than this - I'm not just writing a strange way of creating tuples, I've just simplified it here to explain the problem...
I'm wondering if there's any way to not have to write out every separate case - because especially in the real thing where I've gotta do work for every field - there's a massive amount of duplicate code. So... suppose you wanted to make a function that creates tuples - at the moment I'm doing the equivalent of:
func create<Ta,Tb>( v1 : Ta, v2 : Tb ) -> (Ta, Tb )
{ return (v1, v2);}
func create<Ta,Tb,Tc>( v1: Ta, v2: Tb, v3: Tc) -> (Ta,Tb,Tc)
{ return (v1, v2, v3 );}
func create<Ta,Tb,Tc,Td>( v1 : Ta, v2: Tb, v3: Tc, v4 : Td) -> (Ta, Tb, Tc, Td)
{ return (v1,v2,v3,v4 );}
...
Just wondering if anyone can think of a better way. It's very important that the resulting tuples are typed - ie not some polymorphic collection - because they don't get used like a collection - it wouldn't make sense to iterate over the result - they are all explicitly and separately used by code.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
