# \[Pitch\] Enable pack iteration

**URL:** <https://forums.swift.org/t/pitch-enable-pack-iteration/66168>\
**Category:** Pitches\
**Tags:** variadic-generics\
**Created:** [July 15, 2023, 6:11am UTC](https://forums.swift.org/t/pitch-enable-pack-iteration/66168 "2023-07-15T06:11:44Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ensan-hcl](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ensan-hcl/32/15186_2.png) [@ensan-hcl](https://forums.swift.org/u/ensan-hcl)\
**Post date:** [July 15, 2023, 4:22pm UTC](https://forums.swift.org/t/pitch-enable-pack-iteration/66168/3 "2023-07-15T16:22:44Z")

</div>

I want to do something like this, is it possible?

```swift
func allUnwrapOrNil<each Element>(over element: repeat (each Element)?) -> (repeat each Element)? {
  let result: (repeat each Element)
  for (value, resultTarget) in repeat (each element, each result) {
    guard let value else {
      return nil
    }
    resultTarget = value
  }
  return result
}

```

* * *

This can be just a bikeshedding, but I think generalized `repeat` syntax instead of `for ... in` can be a good alternative.

```swift
func == <each Element: Equatable>(lhs: (repeat each Element), rhs: (repeat each Element)) -> Bool {
  repeat {
    guard each lhs == each rhs else { return false }
  }
  return true
}

```

This way, current `repeat each element` can be considered 'expression' version of `repeat` statement, which makes much consistency with `if` and `switch`.

---

_[View the full topic](https://forums.swift.org/t/pitch-enable-pack-iteration/66168)._
