Home » Swift » What is the limit (if any) to the tuple cardinality in Swift?

What is the limit (if any) to the tuple cardinality in Swift?

Posted by: admin November 30, 2017 Leave a comment

Questions:

Each tuple cardinality is represented by its own type in swift (as in any other strongly-typed programming language I’m aware of), so we have

($T1, $T2)
($T1, $T2, $T3)
...

Since we have several different types, one per cardinality, they need to be finite.

In Scala we have up to Tuple22, in Haskell the current limit should be 64.

What’s the limit (if any) in swift? Also, are the types implementations generated by the compiler or is there an explicit implementation I couldn’t find?

Answers:

In the current version of Xcode 6 Beta, compilation fails with tuples of arity larger than 1948 (the swift executable exits with code 254; there isn’t a specific warning or error).