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

# Kotlin Assignment

The `=` operator in Kotlin is the fundamental assignment operator. It binds the evaluated result of a right-hand side (RHS) expression to a left-hand side (LHS) identifier, establishing either an initial reference in memory or updating an existing mutable reference.

```kotlin theme={"dark"}
identifier = expression
```

## Technical Characteristics

**Statement, Not an Expression**
Unlike languages such as Java or C, the `=` operator in Kotlin is a statement, not an expression. It does not evaluate to or return a value. Consequently, chained assignments are syntactically invalid and will result in a compilation error.

```kotlin theme={"dark"}
var a: Int
var b: Int
// a = b = 5 // Compilation error: Assignments are not expressions
```

**Mutability and Initialization**
The compiler enforces strict rules on the `=` operator based on the LHS declaration:

* **`val` (Read-only):** The `=` operator acts strictly as an initializer. It can only be applied once to bind the initial reference. Subsequent applications result in a `Val cannot be reassigned` compilation error.
* **`var` (Mutable):** The `=` operator acts as both an initializer and a reassignment operator, allowing the LHS identifier to point to new memory addresses or primitive values throughout its lifecycle.

```kotlin theme={"dark"}
val immutableReference: String
immutableReference = "Initialized" // Valid: First assignment (Initialization)
// immutableReference = "Updated"  // Invalid: Reassignment of val

var mutableReference: Int = 1      // Valid: Initialization
mutableReference = 2               // Valid: Reassignment
```

**Type Safety and Variance**
The Kotlin compiler requires that the evaluated type of the RHS expression be identical to, or a valid subtype of, the declared type of the LHS identifier. Implicit narrowing conversions via the `=` operator are prohibited.

```kotlin theme={"dark"}
var number: Number
number = 42       // Valid: Int is a subtype of Number
number = 3.14     // Valid: Double is a subtype of Number

var integer: Int
// integer = number // Invalid: Number is not a subtype of Int
```

**Non-Overloadable**
The basic `=` operator cannot be overloaded. It is a hardcoded language construct. However, compound assignment operators that incorporate `=` (such as `+=`, `-=`, `*=`) can be overloaded by implementing their corresponding `Assign` functions (e.g., `plusAssign`, `minusAssign`) on the target class.

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