TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
|| operator in Kotlin performs a logical disjunction (OR) between two Boolean expressions. It evaluates to true if at least one of the operands is true, and false strictly when both operands are false.
Technical Characteristics
1. Short-Circuit Evaluation Kotlin implements lazy evaluation for the|| operator. The compiler evaluates the left-hand side (LHS) expression first. If the LHS evaluates to true, the overall expression is guaranteed to be true, and the right-hand side (RHS) expression is never evaluated. The RHS is only evaluated if the LHS evaluates to false.
2. Type Constraints
Both operands must resolve to the Boolean type. Kotlin does not support implicit truthiness (e.g., evaluating integers or null references as booleans).
3. Operator Precedence
The || operator has lower precedence than the logical AND operator (&&) and equality operators (==, !=), but higher precedence than assignment operators (=, +=).
4. Non-Overloadable
Unlike arithmetic operators or the bitwise or infix function, the || operator cannot be overloaded via operator overloading. This restriction exists because short-circuiting is a compiler-level control flow mechanism, not a standard function call.
Truth Table and Evaluation Path
Left Operand (LHS) | Right Operand (RHS) | Evaluation Path | Result |
|---|---|---|---|
true | Ignored | LHS only | true |
false | true | LHS → RHS | true |
false | false | LHS → RHS | false |
Syntax Visualization
The following code demonstrates the short-circuiting mechanics using side-effecting functions to visualize execution flow:Master Kotlin with Deep Grasping Methodology!Learn More





