In object-oriented programming, the safe navigation operator (also known as optional chaining operator, safe call operator, null-conditional operator, null-propagation operator) is a binary operator that returns null if its first argument is null; otherwise it performs a dereferencing operation as specified by the second argument (typically an object member access, array index, or lambda invocation).
It is used to avoid sequential explicit null checks and assignments and replace them with method/property chaining. In programming languages where the navigation operator (e.g. ".") leads to an error if applied to a null object, the safe navigation operator stops the evaluation of a method/field chain and returns null as the value of the chain expression. It was first used by Groovy 1.0 in 2007 and is currently supported in languages such as
C#, Swift, TypeScript, Ruby, Kotlin, Rust, JavaScript,
and others. There is currently no common naming convention for this operator, but safe navigation operator is the most widely used term.
The main advantage of using this operator is that it avoids the pyramid of doom. Instead of writing multiple nested codice_1s, programmers can just use usual chaining, but add question mark symbols before dots (or other characters used for chaining).
While the safe navigation operator and null coalescing operator are both null-aware operators, they are operationally different.
Examples.
Apex.
Safe navigation operator examples:
a[x]?.aMethod().aField // Evaluates to null if a[x] == null
a[x].aMethod()?.aField // returns null if a[x].aMethod() evaluates to null
String profileUrl = user.getProfileUrl()?.toExternalForm();
return [SELECT Name FROM Account WHERE Id = :accId]?.Name;
C#.
C# 6.0 and above have codice_2, the "null-conditional member access operator" (which is also called the "Elvis operator" by Microsoft and is not to be confused with the general usage of the term "Elvis operator", whose equivalent in C# is codice_3, the null coalescing operator) and codice_4, the "null-conditional element access operator", which performs a null-safe call of an indexer get accessor. If the type of the result of the member access is a value type, the type of the result of a null-conditional access of that member is a nullable version of that value type.
The following example retrieves the name of the author of the first article in an array of articles (provided that each article has an codice_5 member and that each author has an codice_6 member), and results in codice_7 if the array is codice_7, if its first element is codice_7, if the codice_5 member of that article is codice_7, or if the codice_6 member of that author is codice_7. Note that an codice_14 is still thrown if the array is non-null but empty (i.e. zero-length).
var name = articles?[0]?.Author?.Name;
Calling a lambda requires codice_15, as there is no null-conditional invocation (codice_16 is not allowed).
var result = callback?.Invoke(args);
Clojure.
Clojure doesn't have true operators in the sense other languages uses it, but as it interoperable with Java, and has to perform object navigation when it does, the codice_17 macro can be used to perform safe navigation.
CoffeeScript.
Existential operator:
zip = lottery.drawWinner?().address?.zipcode
Crystal.
Crystal supports the codice_18 safe navigation method 
name = article.try &amp;.author.try &amp;.name
Dart.
Conditional member access operator:var name = article?.author?.name
Gosu.
Null safe invocation operator:
var name = article?.author?.name
The null-safe invocation operator is not needed for class attributes declared as Gosu Properties:
class Foo {
 var _bar: String as Bar
var foo: Foo = null
// the below will evaluate to null and not return a NullPointerException
var bar = foo.Bar
Groovy.
Safe navigation operator and safe index operator:
def name = article?.authors?[0].name
JavaScript.
Added in ECMAScript 2020, the optional chaining operator provides a way to simplify accessing values through connected objects when it's possible that a reference or function may be "undefined" or "null". Major desktop browsers have supported this since 2020, and most mobile browsers added support by 2024. 
const name = article?.authors?.[0]?.name
const result = callback?.()
It short-circuits the whole chain of calls on its right-hand side: in the following example, "bar" is not "accessed".
null?.foo.bar
Kotlin.
Safe call operator:
val name = article?.author?.name
Objective-C.
Normal navigation syntax can be used in most cases without regarding NULLs, as the underlying messages, when sent to NULL, is discarded without any ill effects.
NSString *name = article.author[0].name;
Perl 5.
Perl 5 does not have this kind of operator, but a proposal for inclusion was accepted with the following syntax:
my $name = $article?- ;author?- ;name;
PHP.
The null safe operator was accepted for PHP 8:
$name = $article?- ;author?- ;name;
Raku (Perl 6).
Safe method call:
my $name = $article.?author.?name;
Ruby.
Ruby supports the codice_19 safe navigation operator (also known as the "lonely operator") since version 2.3.0:
name = article&amp;.author&amp;.name
Rust.
Rust provides a codice_20 operator that can seem like a safe navigation operator. However, a key difference is that when codice_20 encounters a codice_22 value, it doesn't evaluate to codice_22. Instead, it behaves like a codice_24 statement, causing the enclosing function or closure to immediately return codice_22.
The codice_26 methods codice_27 and codice_28 can be used for safe navigation, but this option is more verbose than a safe navigation operator:
fn print_author(article: Option ;Article ;) {
 println!(
 "Author: {}",
 article.and_then(|y| y.author)
 .map(|z| z.name)
 .unwrap_or("Unknown".to_owned())
An implementation using codice_20 will print nothing (not even "Author:") if codice_30 is codice_22 or codice_32 is codice_22. As soon as codice_20 sees a codice_22, the function returns.
fn try_print_author(article: Option ;Article ;) - ; Option ;() ;{
 println!("Author: {}", article?.author?.name);
 Some(())
Scala.
The null-safe operator in Scala is provided by the library Dsl.scala. 
val name = article.?.author.?.name : @ ?
The codice_36 annotation can be used to denote a nullable value.
case class Tree(left: Tree @ ? = null, right: Tree @ ? = null, value: String @ ? = null)
val root: Tree @ ? = Tree(
 left = Tree(
 left = Tree(value = "left-left"),
 right = Tree(value = "left-right")
 right = Tree(value = "right")
The normal codice_37 in Scala is not null-safe, when performing a method on a codice_7 value.
a[NullPointerException] should be thrownBy {
root.right.left.right.value // root.right.left is null!
The exception can be avoided by using codice_20 operator on the nullable value instead:
root.?.right.?.left.?.value should be(null)
The entire expression is codice_7 if one of codice_20 is performed on a codice_7 value.
The boundary of a codice_7 safe operator codice_20 is the nearest enclosing expression whose type is annotated as codice_36.
Swift.
Optional chaining operator, subscript operator, and call:
let name = article?.authors?[0].name
let result = protocolVar?.optionalRequirement?()
TypeScript.
Optional chaining operator was included in the Typescript 3.7 release:
let x = foo?.bar?.[0]?.baz();
Visual Basic .NET.
Visual Basic 14 and above have the codice_2 (the "null-conditional member access operator") and codice_47 (the "null-conditional index operator"), similar to C#. They have the same behavior as the equivalent operators in C#.
The following statement behaves identically to the C# example above.
Dim name = articles?(0)?.Author?.Name
References.
 ;templatestyles src="Reflist/styles.css" / ;