?. (null-safe method) operator

The left-associative, binary ?. operator is used to invoke a method as if its right-hand operand were not null.

Usage

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

Description

Definition

See the language specification for more details.

Polymorphism

The ?. operator is not polymorphic.

Type

The result type of the lhs?.rhs operator is the callable type of the right hand operand, with the return type replaced by its corresponding optional type.

See also