> ## 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 Division Assignment

The `/=` operator is a compound assignment operator that divides the value of the left-hand operand by the value of the right-hand operand, subsequently assigning the resulting quotient directly back to the left-hand operand.

## Syntax

```swift theme={"dark"}
lhs /= rhs
```

This operation is semantically equivalent to the expanded assignment and division expression:

```swift theme={"dark"}
lhs = lhs / rhs
```

## Technical Characteristics

* **Mutability Requirement:** The left-hand operand (`lhs`) must be declared as a mutable variable (using `var`). It cannot be a constant (`let`) or an immutable literal, as the operator mutates the operand in place. Under the hood, the left-hand operand is passed as an `inout` parameter to the operator's underlying function.
* **Type Strictness:** Swift requires strict type matching. Both `lhs` and `rhs` must be of the same type, or the compiler will throw an error. Swift does not perform implicit type coercion between different numeric types (e.g., `Int` and `Double`).
* **Integer vs. Floating-Point Behavior:**
  * When applied to integer types (e.g., `Int`, `UInt8`), the operator performs truncating division. Any fractional component of the quotient is discarded towards zero.
  * When applied to floating-point types (e.g., `Double`, `Float`), the operator retains the fractional component according to IEEE 754 standard arithmetic.
* **Division by Zero:**
  * For integer types, attempting to divide by zero using `/=` triggers a runtime trap (fatal error), intentionally crashing the application to prevent undefined behavior.
  * For floating-point types, division by zero results in `inf` (infinity) or `-inf`, while dividing zero by zero results in `nan` (Not a Number), adhering to standard floating-point specifications without crashing.

## Operator Overloading

The `/=` operator can be implemented for custom data types (such as custom structs or classes) by overloading the operator. This is achieved by defining a `static func` where the left-hand operand is marked as `inout`.

```swift theme={"dark"}
static func /= (lhs: inout CustomType, rhs: CustomType) {
    // Implementation mutating lhs
}
```

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