> ## 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 Void

In Swift, `Void` is a type alias for an empty tuple, representing the absence of a specific value. Unlike C-family languages where `void` is a compiler keyword indicating "nothing," Swift's `Void` is a first-class type within the type system.

In the Swift Standard Library, `Void` is explicitly defined as:

```swift theme={"dark"}
public typealias Void = ()
```

## Type and Value Equivalence

Because `Void` is merely an alias, the identifier `Void` (the type) and `()` (the empty tuple type) are strictly interchangeable. Furthermore, the only possible instance (value) of the `Void` type is the empty tuple value `()`.

```swift theme={"dark"}
// Type declaration using Void
let explicitVoid: Void = ()

// Type declaration using the empty tuple type
let implicitVoid: () = ()
```

## Function Signatures

When a function or closure does not explicitly declare a return type, the Swift compiler implicitly assigns it a return type of `Void`. The following three function declarations are semantically identical after type checking. However, because the Swift Abstract Syntax Tree (AST) preserves source fidelity, the syntactic differences (omitted return type vs. `-> Void` vs. `-> ()`) are represented by distinct type representation nodes in the AST:

```swift theme={"dark"}
func executeOperationA() { }
func executeOperationB() -> Void { }
func executeOperationC() -> () { }
```

Similarly, if a function returns `Void`, the compiler implicitly inserts a `return ()` statement at the end of the function body. You can explicitly return the empty tuple value, though it is syntactically redundant:

```swift theme={"dark"}
func terminate() -> Void {
    // Implicitly returns ()
    return () 
}
```

## Memory Layout

Because `Void` contains no elements, instances of `Void` carry no data. Consequently, the Swift compiler optimizes `Void` to have a size of zero bytes.

```swift theme={"dark"}
MemoryLayout<Void>.size      // 0 bytes
MemoryLayout<Void>.alignment // 1 byte
MemoryLayout<Void>.stride    // 1 byte
```

*Note: While the `size` is 0, the `stride` and `alignment` are 1. Swift requires all types to have a minimum stride of 1 byte so that distinct elements in a contiguous memory block (like an `Array<Void>`) have unique memory addresses.*

## Generics Integration

Because `Void` is a standard type rather than a special keyword, it satisfies generic type constraints just like `Int`, `String`, or any custom `struct`. When a generic placeholder resolves to `Void`, the compiler substitutes the empty tuple type, and the generic type expects the empty tuple value `()`.

```swift theme={"dark"}
// Void satisfying the generic type parameter 'Success' in Result<Success, Failure>
let successState: Result<Void, Error> = .success(())

// Void satisfying a generic parameter in a custom structure
struct Container<T> {
    let payload: T
}

let emptyContainer = Container<Void>(payload: ())
```

<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>
