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.
?. (safe call) operator is a null-safety mechanism in Kotlin that performs conditional member access. It evaluates the receiver expression and, if the receiver is non-null, executes the property access or function call. If the receiver evaluates to null, the operator short-circuits the evaluation and immediately returns null without throwing a NullPointerException.
Syntax and Evaluation
The operator is placed directly between the nullable receiver and the member (property or function) being accessed.Type System Implications
The safe call operator alters the inferred return type of the expression by forcing it to be nullable, regardless of the member’s original return type. Ifreceiver.member resolves to a non-nullable type T, the expression receiver?.member will resolve to the nullable type T?.
Short-Circuiting in Chains
When multiple safe call operators are chained sequentially, the expression evaluates from left to right. The firstnull encountered in the chain immediately halts further evaluation, short-circuiting the rest of the expression and yielding null for the entire chain.
- If
objectAisnull,propertyB,propertyC, andmethodD()are never evaluated. - If
objectAis non-null butpropertyBisnull, the chain halts before accessingpropertyC.
Short-Circuiting in Assignments
When the safe call operator is used on the left-hand side of an assignment, the short-circuiting behavior extends to the right-hand side expression. If the receiver isnull, the assignment is skipped entirely, and the expression on the right is never evaluated.
Master Kotlin with Deep Grasping Methodology!Learn More





