?. (null-safe attribute) operator

The left-associative, binary ?. operator is used to access an attribute as if its right-hand operand were not null.

Usage

void m(Integer? num) {
    Integer? int = num?.positiveValue;
}

Description

Definition

The meaning of ?. is defined as follows:

if (exists lhs) lhs.member else null    

Polymorphism

The ?. operator is not polymorphic.

Type

The result type of the lhs?.rhs operator is the optional type of the right hand operand.

See also