optional chaining¶
a?.b short-circuits to None when a is None, otherwise evaluates a.b:
transpiles to:
chains¶
each ?. introduces a new short-circuit guard. multi-step chains share a
temp variable so each prefix is evaluated only once:
transpiles to:
mixed chains — ?. followed by regular . — only guard at the explicit
optional steps:
a.b?.c works in the obvious way: only the part after a.b is short-circuited
through a temp variable
scope¶
?. is recognized in attribute-access expressions only. method calls,
subscripts, and arbitrary call expressions on the optional value are not yet
supported in the surface syntax — fall back to a guard expression
interaction with ??¶
see none-coalesce operator. ?. composes with ??
without re-evaluating the chained prefix