> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Swift Wildcard Pattern

The wildcard pattern (`_`) is a syntactic construct in Swift used to match and explicitly ignore any value during pattern matching, assignment, or iteration. It acts as an anonymous placeholder that satisfies arity and structural requirements without binding the underlying value to a named variable in the local scope.

## Mechanics

When the Swift compiler encounters a wildcard pattern, it performs the following operations:

* **Expression Evaluation:** The expression yielding the value is fully evaluated, ensuring any side effects of the expression still occur.
* **Value Discarding:** The resulting value is immediately discarded.
* **Memory Management:** No memory is allocated for a local variable binding. However, if the evaluated expression returns an owned reference type, Automatic Reference Counting (ARC) must still perform a `release` operation immediately after evaluation to properly destroy and deallocate the discarded value.
* **Warning Suppression:** It explicitly signals to the compiler that the omission of a variable binding is intentional, suppressing "unused value" warnings.

## Syntax and Structural Application

The wildcard pattern can be substituted anywhere a standard identifier pattern or value-binding pattern is expected.

**Standalone Assignment**
Absorbs the return value of a function or expression to satisfy the compiler when the result is unneeded.

```swift theme={"dark"}
_ = expressionReturningValue()
```

**Tuple Decomposition**
Selectively ignores specific elements within a compound type while extracting others. The wildcard maintains the structural arity of the tuple during decomposition.

```swift theme={"dark"}
let (_, y, _) = (10.0, 20.0, 30.0)
```

**Control Flow Iteration**
Satisfies the syntax requirements of a `for-in` loop when the current iteration index or sequence element is not referenced in the execution block.

```swift theme={"dark"}
for _ in 0..<5 {
    // Execution block
}
```

**Enumeration Associated Values**
Matches an enumeration case within `switch` statements or `if case` constructs while discarding one or more of its associated payload values.

```swift theme={"dark"}
enum NetworkError: Error {
    case notFound
}

enum NetworkResponse {
    case success(String)
    case failure(Int, Error)
}

let response: NetworkResponse = .failure(404, NetworkError.notFound)

switch response {
case .success(_):
    break // Matches .success regardless of the associated payload
case .failure(_, let error):
    print(error) // Ignores the first associated value (Int), binds the second (Error)
}
```

**Closure Parameters**
Satisfies a closure's expected type signature and parameter count without naming parameters that will not be invoked within the closure body.

```swift theme={"dark"}
let closure: (Int, String) -> Void = { _, _ in
    // Execution block
}
```

**Function Argument Labels**
Omits the external argument label in function and method declarations. While technically classified by the Swift grammar as an omitted argument label rather than a strict pattern, it utilizes the identical wildcard syntax and conceptual behavior to allow callers to pass arguments without naming them at the call site.

```swift theme={"dark"}
func process(_ input: String) {
    // Execution block
}
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor Swift Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
