# \#tuple

**URL:** https://forums.swift.org/tag/tuple/175.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Why are tuples allowed to be only partially initialized?](https://forums.swift.org/t/why-are-tuples-allowed-to-be-only-partially-initialized/85766)

<div class="topic-metadata">

**Author:** [@jamieQ](https://forums.swift.org/u/jamieQ)\
**Replies:** 4\
**Last updated:** [April 2, 2026, 9:44pm UTC](https://forums.swift.org/t/why-are-tuples-allowed-to-be-only-partially-initialized/85766 "2026-04-02T21:44:12Z")

</div>

The following is, I think, primarily a curiosity that I came across, but it got me wondering – what is Swift's model for the initialization of tuples? Nominal types all seemingly must be fully initialized before use, but…

---

## [\[Pitch\] Automatic \`Hashable\` Conformance for Tuples (Revival of SE-0283)](https://forums.swift.org/t/pitch-automatic-hashable-conformance-for-tuples-revival-of-se-0283/83105)

<div class="topic-metadata">

**Author:** [@joshuacleetus](https://forums.swift.org/u/joshuacleetus)\
**Replies:** 13\
**Last updated:** [March 16, 2026, 12:38am UTC](https://forums.swift.org/t/pitch-automatic-hashable-conformance-for-tuples-revival-of-se-0283/83105 "2026-03-16T00:38:36Z")

</div>

\[Pitch\] Automatic \`Hashable\` Conformance for Tuples (Revival of SE-0283) UPDATE (Nov 2025): Incorporated feedback from @Slava\_Pestov and @allevato – removed invalid syntax, clarified \`Array\` hashing, removed non-existen…

---

## [Large tuples become FixedTupleTypeInfo (non-loadable, too big for registers) rather than LoadableTupleTypeInfo](https://forums.swift.org/t/large-tuples-become-fixedtupletypeinfo-non-loadable-too-big-for-registers-rather-than-loadabletupletypeinfo/85216)

<div class="topic-metadata">

**Author:** [@tjcrna2012](https://forums.swift.org/u/tjcrna2012)\
**Replies:** 2\
**Last updated:** [March 9, 2026, 4:28pm UTC](https://forums.swift.org/t/large-tuples-become-fixedtupletypeinfo-non-loadable-too-big-for-registers-rather-than-loadabletupletypeinfo/85216 "2026-03-09T16:28:40Z")

</div>

When initializing a large tuple of trivially-copyable types in embedded Swift, the compiler generates individual field copy operations for each element instead of using a single memcpy. For a 64-element tuple, this gener…

---

## [Declaring part of a tuple as nonisolated(unsafe)](https://forums.swift.org/t/declaring-part-of-a-tuple-as-nonisolated-unsafe/82466)

<div class="topic-metadata">

**Author:** [@sspringer](https://forums.swift.org/u/sspringer)\
**Replies:** 1\
**Last updated:** [October 1, 2025, 6:29pm UTC](https://forums.swift.org/t/declaring-part-of-a-tuple-as-nonisolated-unsafe/82466 "2025-10-01T18:29:37Z")

</div>

I would like to declare one part of a tuple as nonisolated(unsafe) in a global declaration: let (nonisolated(unsafe) a, b) = ... a is a regex, b a String. I am using a tuple because this tuple is created by a macro usi…

---

## [Why can you label inaccessible tuple elements in a for loop?](https://forums.swift.org/t/why-can-you-label-inaccessible-tuple-elements-in-a-for-loop/81985)

<div class="topic-metadata">

**Author:** [@Danny](https://forums.swift.org/u/Danny)\
**Replies:** 4\
**Last updated:** [September 6, 2025, 4:11pm UTC](https://forums.swift.org/t/why-can-you-label-inaccessible-tuple-elements-in-a-for-loop/81985 "2025-09-06T16:11:09Z")

</div>

Is there utility in this? for (int, bool) in \[(1, true)\] { print(bool, int) // Compiles } for tuple: (int: Int, bool: Bool) in \[(1, true)\] { print(tuple.bool, tuple.int) // Compiles. } for (int: Int, bool: Bool) i…

---

## [Borrowing: Works with struct but fails with tuple](https://forums.swift.org/t/borrowing-works-with-struct-but-fails-with-tuple/81444)

<div class="topic-metadata">

**Author:** [@saulpalv](https://forums.swift.org/u/saulpalv)\
**Replies:** 3\
**Last updated:** [August 3, 2025, 11:34am UTC](https://forums.swift.org/t/borrowing-works-with-struct-but-fails-with-tuple/81444 "2025-08-03T11:34:17Z")

</div>

I have a code that has same data in two forms Tuple and Struct, they are both tested by converting to the same Final Struct, however the code only compiles for the struct whereas fails for the tuple, is there something f…

---

## [Parameter packs, same-shape requirements, and spreading arrays](https://forums.swift.org/t/parameter-packs-same-shape-requirements-and-spreading-arrays/79043)

<div class="topic-metadata">

**Author:** [@NSExceptional](https://forums.swift.org/u/NSExceptional)\
**Replies:** 4\
**Last updated:** [April 5, 2025, 11:10pm UTC](https://forums.swift.org/t/parameter-packs-same-shape-requirements-and-spreading-arrays/79043 "2025-04-05T23:10:02Z")

</div>

A few things that I wish I could do with parameter packs appear to be impossible. I'll outline my use case here. I'm working with SwiftSyntax, looking for instances of layer.cornerRadius = blah: let list = CodeBlockIte…

---

## [Is there a way to reverse a tuple?](https://forums.swift.org/t/is-there-a-way-to-reverse-a-tuple/74831)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 3\
**Last updated:** [September 22, 2024, 1:04pm UTC](https://forums.swift.org/t/is-there-a-way-to-reverse-a-tuple/74831 "2024-09-22T13:04:25Z")

</div>

Is there a way (in Swift 6) to reverse the members of a tuple, i.e. given a tuple of type (A, B, C), return a tuple of (C, B, A)? It still needs to work when the variadic length is 0 or 1.

---

## [Are these "tuple splat" parameterized tests legit?](https://forums.swift.org/t/are-these-tuple-splat-parameterized-tests-legit/73250)

<div class="topic-metadata">

**Author:** [@vanvoorden](https://forums.swift.org/u/vanvoorden)\
**Replies:** 2\
**Last updated:** [July 18, 2024, 4:14am UTC](https://forums.swift.org/t/are-these-tuple-splat-parameterized-tests-legit/73250 "2024-07-18T04:14:21Z")

</div>

Hi! I'm experimenting with parameterized testing in swift-testing. The documentation (and WWDC videos) I found highlight examples of: Passing a single sequence (to a test that accepts one parameter). Passing two sequen…

---

## [Execution Order of Awaited Tuples](https://forums.swift.org/t/execution-order-of-awaited-tuples/72834)

<div class="topic-metadata">

**Author:** [@Jens](https://forums.swift.org/u/Jens)\
**Replies:** 2\
**Last updated:** [June 30, 2024, 12:35pm UTC](https://forums.swift.org/t/execution-order-of-awaited-tuples/72834 "2024-06-30T12:35:44Z")

</div>

While writing some tests, I noticed that this await \_ = ( someAsyncFunc(), someAsyncFunc() ) seems to be equivalent to await someAsyncFunc() await someAsyncFunc() I.e. the second call is executed after the first …

---

## [How can we get the last member of a tuple?](https://forums.swift.org/t/how-can-we-get-the-last-member-of-a-tuple/72308)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 1\
**Last updated:** [June 7, 2024, 6:46pm UTC](https://forums.swift.org/t/how-can-we-get-the-last-member-of-a-tuple/72308 "2024-06-07T18:46:20Z")

</div>

We can use "myTuple.0" to get the first member of a tuple. Is there a similar way for the last member? The members are static numbers (AIUI), so "myTuple.(count - 1)" can't work. I'm interested because of variadic gener…

---

## [How do I use the individual members of variadic data?](https://forums.swift.org/t/how-do-i-use-the-individual-members-of-variadic-data/71654)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 0\
**Last updated:** [May 7, 2024, 12:08am UTC](https://forums.swift.org/t/how-do-i-use-the-individual-members-of-variadic-data/71654 "2024-05-07T00:08:18Z")

</div>

Lapsed coder. Read about variadic generics finally getting into the language. Tried out an example in a playground, couldn't figure out how to make it work. struct MyType\<First: Comparable, Second: Comparable, each Suff…

---

## [Did the subtyping rules for tuple labels change in Swift 6?](https://forums.swift.org/t/did-the-subtyping-rules-for-tuple-labels-change-in-swift-6/71408)

<div class="topic-metadata">

**Author:** [@taylorswift](https://forums.swift.org/u/taylorswift)\
**Replies:** 2\
**Last updated:** [April 23, 2024, 8:36pm UTC](https://forums.swift.org/t/did-the-subtyping-rules-for-tuple-labels-change-in-swift-6/71408 "2024-04-23T20:36:00Z")

</div>

i attempted to build the swift-png package with a nightly Swift 6.0 compiler. Sources/LZ77/HuffmanCoding/LZ77.HuffmanTree.swift:95:63: error: cannot convert sequence element type '(offset: Int, element: Range\<Int\>)' to …

---

## [Tuples with default values idea](https://forums.swift.org/t/tuples-with-default-values-idea/70841)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 3\
**Last updated:** [March 22, 2024, 2:31pm UTC](https://forums.swift.org/t/tuples-with-default-values-idea/70841 "2024-03-22T14:31:28Z")

</div>

Got this rough idea of allowing default values in tuples: typealias T = (Int, Double, String = "") T(1, 2) // ✅ func foo(\_ v: (Int, Double, String = "")) {} foo((1, 2)) // ✅ typealias R = (x: Int, …

---

## [Array constructor from Mirror Subject?](https://forums.swift.org/t/array-constructor-from-mirror-subject/69781)

<div class="topic-metadata">

**Author:** [@jtint24](https://forums.swift.org/u/jtint24)\
**Replies:** 2\
**Last updated:** [February 2, 2024, 1:32am UTC](https://forums.swift.org/t/array-constructor-from-mirror-subject/69781 "2024-02-02T01:32:07Z")

</div>

This would be a new initializer for Array, allowing it to be created from a Subject, targeted at providing greater ease-of-use to tuples. The problem with Tuples Homogenous tuples are already the standard way of represe…

---

## [Tuple Destructuring in computed properties](https://forums.swift.org/t/tuple-destructuring-in-computed-properties/67909)

<div class="topic-metadata">

**Author:** [@bryan](https://forums.swift.org/u/bryan)\
**Replies:** 8\
**Last updated:** [October 17, 2023, 10:39pm UTC](https://forums.swift.org/t/tuple-destructuring-in-computed-properties/67909 "2023-10-17T22:39:41Z")

</div>

Destructuring tuples is a very common way to improve the use of Tuples. It does not work with computed properties. Take this code for example: var hourMinute: (Int, Int) { let date = Date() let cal = Calendar.c…

---

## [ExpressibleByTupleLiteral](https://forums.swift.org/t/expressiblebytupleliteral/66435)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 5\
**Last updated:** [July 28, 2023, 6:54pm UTC](https://forums.swift.org/t/expressiblebytupleliteral/66435 "2023-07-28T18:54:36Z")

</div>

By conforming my type to a "ExpressibleBy...Literal" protocol: struct S { var x, y, z: Int } I can initialise it like so: let s: S = \["x": 1, "y": 2, "z": 3\] // via ExpressibleByDictionaryLiteral let s: S = \[1, 2,…

---

## [Implicitly unwrapped optionals in tuples](https://forums.swift.org/t/implicitly-unwrapped-optionals-in-tuples/66434)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 2\
**Last updated:** [July 28, 2023, 3:05pm UTC](https://forums.swift.org/t/implicitly-unwrapped-optionals-in-tuples/66434 "2023-07-28T15:05:25Z")

</div>

I can use implicitly unwrapped optionals in structs and enums but not tuples: struct A { var x: Int!, y: Float! } // ✅ enum B { case x(Int!), y(Float!) } // ✅ typealias C = (x: Int!, y: Float!) // 🛑 Using '!' is not a…

---

## [Enum tuple case composing/decomposing disparity](https://forums.swift.org/t/enum-tuple-case-composing-decomposing-disparity/66406)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 4\
**Last updated:** [July 27, 2023, 2:24pm UTC](https://forums.swift.org/t/enum-tuple-case-composing-decomposing-disparity/66406 "2023-07-27T14:24:54Z")

</div>

In this example: typealias Tuple = (first: Int, second: Int) enum TupleEnum { case tuple(Tuple) } func foo(value: TupleEnum) { switch value { // case let .tuple(t: Tuple): break // no brainer // case l…

---

## [Homogeneous tuples](https://forums.swift.org/t/homogeneous-tuples/63873)

<div class="topic-metadata">

**Author:** [@tera](https://forums.swift.org/u/tera)\
**Replies:** 8\
**Last updated:** [July 23, 2023, 6:38pm UTC](https://forums.swift.org/t/homogeneous-tuples/63873 "2023-07-23T18:38:14Z")

</div>

SE-0393: Value and Type Parameter Packs mentions "Tuple conformances" in its "future direction" section. To not sidetrack that thread let me present a raw idea about tuples here. Homogenious Tuples Motivation Currently…

---

## [Tuple of value pack expansion](https://forums.swift.org/t/tuple-of-value-pack-expansion/64269)

<div class="topic-metadata">

**Author:** [@sophia](https://forums.swift.org/u/sophia)\
**Replies:** 19\
**Last updated:** [July 23, 2023, 5:50pm UTC](https://forums.swift.org/t/tuple-of-value-pack-expansion/64269 "2023-07-23T17:50:39Z")

</div>

co-author: Holly Borla Introduction Building upon the Value and Type Parameter Packs proposal SE-0393, this proposal enables referencing a tuple value that contains a value pack inside a pack repetition pattern. Motiva…

---

## [Stray thought: Mapping over tuple values](https://forums.swift.org/t/stray-thought-mapping-over-tuple-values/19719)

<div class="topic-metadata">

**Author:** [@Morten\_Bek\_Ditlevsen](https://forums.swift.org/u/Morten_Bek_Ditlevsen)\
**Replies:** 3\
**Last updated:** [September 16, 2022, 9:19am UTC](https://forums.swift.org/t/stray-thought-mapping-over-tuple-values/19719 "2022-09-16T09:19:34Z")

</div>

I just encountered a small thing that perhaps could be expressed even better in Swift at some point in the future. Perhaps it has to do with Variadic Generics or extending non-nominal types, but I am not 100% sure: I ha…

---

## [Swift optional unwrap string tuple](https://forums.swift.org/t/swift-optional-unwrap-string-tuple/49450)

<div class="topic-metadata">

**Author:** [@swifto](https://forums.swift.org/u/swifto)\
**Replies:** 1\
**Last updated:** [June 10, 2021, 5:27am UTC](https://forums.swift.org/t/swift-optional-unwrap-string-tuple/49450 "2021-06-10T05:27:42Z")

</div>

I have a function which returns a string tuple with optional values (String?,String?). Trying to handle this with the help of switch case . func getResult() -\> (String?,String?) { return (nil,nil)// Could be John,nil…

---

## [Tuple labels in generic constraints](https://forums.swift.org/t/tuple-labels-in-generic-constraints/46934)

<div class="topic-metadata">

**Author:** [@Karl](https://forums.swift.org/u/Karl)\
**Replies:** 3\
**Last updated:** [March 31, 2021, 4:49pm UTC](https://forums.swift.org/t/tuple-labels-in-generic-constraints/46934 "2021-03-31T16:49:16Z")

</div>

Hi, I'm having an issue with a generic function which accepts a collection of tuples: struct Foo { public mutating func append\<CollectionType, StringType\>( contentsOf keyValuePairs: CollectionType ) where Colle…

---

## [SR-14244: Tuple containing one or more closures is expanded incorrectly in source editor](https://forums.swift.org/t/sr-14244-tuple-containing-one-or-more-closures-is-expanded-incorrectly-in-source-editor/44889)

<div class="topic-metadata">

**Author:** [@orchetect](https://forums.swift.org/u/orchetect)\
**Replies:** 0\
**Last updated:** [February 18, 2021, 9:07pm UTC](https://forums.swift.org/t/sr-14244-tuple-containing-one-or-more-closures-is-expanded-incorrectly-in-source-editor/44889 "2021-02-18T21:07:32Z")

</div>

I stumbled on a source parsing bug affecting Xcode's parameter expansion, and from my vetting of JIRA and the forums I don't think it's been reported yet, so I dropped a bug report into JIRA outlining this behavior. Obs…

---

## [Protocol Conformance for Tuples / Anonymous Structs](https://forums.swift.org/t/protocol-conformance-for-tuples-anonymous-structs/24207)

<div class="topic-metadata">

**Author:** [@pxheller](https://forums.swift.org/u/pxheller)\
**Replies:** 40\
**Last updated:** [July 27, 2020, 2:44am UTC](https://forums.swift.org/t/protocol-conformance-for-tuples-anonymous-structs/24207 "2020-07-27T02:44:01Z")

</div>

Currently, if you wish to pass some data to a function that requires the data to conform to a specific protocol, you have to define some type that conforms to the protocol and create an object with that type afterward. F…

---

## [This comparison shouldn't need tuple conformance to Equatable, right?](https://forums.swift.org/t/this-comparison-shouldnt-need-tuple-conformance-to-equatable-right/36464)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 6\
**Last updated:** [May 15, 2020, 6:41am UTC](https://forums.swift.org/t/this-comparison-shouldnt-need-tuple-conformance-to-equatable-right/36464 "2020-05-15T06:41:15Z")

</div>

I'm using Xcode version 11.4.1 (11E503a) on a Catalina system, with a playground. extension Sequence { /// Returns the first corresponding pair of elements from this sequence and /// the given sequence that are…

---

## [Tuple \`as struct\`](https://forums.swift.org/t/tuple-as-struct/33851)

<div class="topic-metadata">

**Author:** [@Dan\_Stenmark](https://forums.swift.org/u/Dan_Stenmark)\
**Replies:** 3\
**Last updated:** [February 16, 2020, 10:15pm UTC](https://forums.swift.org/t/tuple-as-struct/33851 "2020-02-16T22:15:15Z")

</div>

Based on recently active topics such as Tuples conform to Equatable and Anonymous Structs, I'd like to throw my own pre-pitch onto the table as well: as struct syntax. It's common for libraries to support functions that…

---

## [Special Case Protocol Conformance: Long-term Tradeoffs for Near-term Conformance](https://forums.swift.org/t/special-case-protocol-conformance-long-term-tradeoffs-for-near-term-conformance/33544)

<div class="topic-metadata">

**Author:** [@mattrips](https://forums.swift.org/u/mattrips)\
**Replies:** 41\
**Last updated:** [February 16, 2020, 3:46am UTC](https://forums.swift.org/t/special-case-protocol-conformance-long-term-tradeoffs-for-near-term-conformance/33544 "2020-02-16T03:46:07Z")

</div>

Recently, @Alejandro launched the Tuples Conform to Equatable pitch, along with a proposed implementation. This thread, here, is for purposes of discussing the long-term tradeoffs that may result from the near-term adop…

---

## [Tuple subtypes (by labels)](https://forums.swift.org/t/tuple-subtypes-by-labels/33641)

<div class="topic-metadata">

**Author:** [@CTMacUser](https://forums.swift.org/u/CTMacUser)\
**Replies:** 2\
**Last updated:** [February 9, 2020, 5:55pm UTC](https://forums.swift.org/t/tuple-subtypes-by-labels/33641 "2020-02-09T17:55:56Z")

</div>

Continuing the discussion from Tuples conform to Equatable: I know that functions that take an Optional parameter can use a non-optional instance as an argument. Do tuples have the same relationship? I mean that is a…

[Next page](https://forums.swift.org/tag/tuple/175.md?match_all_tags=true&page=1&tags%5B%5D=tuple)
