safe navigation operator
English
editNoun
editsafe navigation operator (plural safe navigation operators)
- (programming) A binary operator that returns its second argument, unless the first argument is null, in which case it returns null; used to simplify code that would otherwise need multiple explicit checks for nullity.
- 2009, Bashar Jawad, Groovy and Grails Recipes, page 57:
- One operator I haven't talked about yet is the safe navigation operator (
?.
). By preceding a dot with a question mark, you can safely navigate to methods or properties of an object even if that object is null.
- 2015, Mert Caliskan, Kenan Sevindik, Beginning Spring, page 278:
- The safe navigation operator (
?.
) provides navigation on the nested properties without getting any exception when a null value is evaluated from any of the properties iterated.
- 2017, Gary McLean Hall, Adaptive Code: Agile coding with design patterns and SOLID principles:
- C# 6 introduced a cascading nulls operator, also called the null-conditional operator and the safe navigation operator.