An Entity of Type: Thing, from Named Graph: http://dbpedia.org, within Data Space: dbpedia.org

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). While the safe navigation operator and null coalescing operator are both null-aware operators, they are operationally different.

Property Value
dbo:abstract
  • 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 asC#,Swift, TypeScript, Ruby,Kotlin,Rustand 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 ifs, 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. (en)
  • Null条件演算子 (英: null-conditional operator) とは、第一項がnull(ヌルポインタ: null pointerまたはヌル参照: null reference)でない場合に第二項の結果を返し、nullである場合にnullを返す演算子である。nullでないことのチェック処理の記述を回避し、安全にメソッドチェーンやプロパティチェーンを行うために用いられる。メンバーアクセス演算子.は第一項がnullの場合に実行時エラー(例えばJavaの場合NullPointerException)が発生するが、Null条件演算子の場合はnullの検出が自動化され、以降のメソッド呼び出しやフィールド/プロパティの評価を行わずにnullをその結果として返す。Null条件演算子はGroovy、Swift、Ruby、C#、VB.NET、Kotlin、CoffeeScriptなどで実装されている。Null条件演算子は言語によってsafe navigation operator、optional chaining operator、safe call operator、null-conditional operatorなど様々な名称で呼ばれ、共通した名称はないが、英語圏においてはsafe navigation operatorが広く用いられる。 Null条件演算子を使用する主な利点は、nullチェック時に過剰にネストが深くなる問題 を回避できることである。 (ja)
  • 在面向对象程序设计中,安全导航运算符(safe navigation operator,也可称作optional chaining operator、safe call operator、null-conditional operator)是一个二元运算符,在第一个实参为空值时返回空值,否则按照第二个实参执行解引用(dereference)操作(典型如对象成员访问,数组索引,lambda调用)。 在编程语言中,导航运算符(navigation operator,例如 ".") 如果应用到空对象将会导致一个错误。安全导航运算符在这种情况下会中止对方法或者字段的链式求值并返回空值。这避免了顺序地显式空值检查。主要优点是避免了诅咒金字塔现象。不必写多层嵌套if语句,编程者可以写正常的链式表达式。 安全导航运算符与空值结合运算符二者都是空值感知运算符(null-aware operator)。 (zh)
dbo:wikiPageExternalLink
dbo:wikiPageID
  • 49249693 (xsd:integer)
dbo:wikiPageLength
  • 14924 (xsd:nonNegativeInteger)
dbo:wikiPageRevisionID
  • 1116990788 (xsd:integer)
dbo:wikiPageWikiLink
dbp:wikiPageUsesTemplate
dcterms:subject
rdfs:comment
  • 在面向对象程序设计中,安全导航运算符(safe navigation operator,也可称作optional chaining operator、safe call operator、null-conditional operator)是一个二元运算符,在第一个实参为空值时返回空值,否则按照第二个实参执行解引用(dereference)操作(典型如对象成员访问,数组索引,lambda调用)。 在编程语言中,导航运算符(navigation operator,例如 ".") 如果应用到空对象将会导致一个错误。安全导航运算符在这种情况下会中止对方法或者字段的链式求值并返回空值。这避免了顺序地显式空值检查。主要优点是避免了诅咒金字塔现象。不必写多层嵌套if语句,编程者可以写正常的链式表达式。 安全导航运算符与空值结合运算符二者都是空值感知运算符(null-aware operator)。 (zh)
  • 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). While the safe navigation operator and null coalescing operator are both null-aware operators, they are operationally different. (en)
  • Null条件演算子 (英: null-conditional operator) とは、第一項がnull(ヌルポインタ: null pointerまたはヌル参照: null reference)でない場合に第二項の結果を返し、nullである場合にnullを返す演算子である。nullでないことのチェック処理の記述を回避し、安全にメソッドチェーンやプロパティチェーンを行うために用いられる。メンバーアクセス演算子.は第一項がnullの場合に実行時エラー(例えばJavaの場合NullPointerException)が発生するが、Null条件演算子の場合はnullの検出が自動化され、以降のメソッド呼び出しやフィールド/プロパティの評価を行わずにnullをその結果として返す。Null条件演算子はGroovy、Swift、Ruby、C#、VB.NET、Kotlin、CoffeeScriptなどで実装されている。Null条件演算子は言語によってsafe navigation operator、optional chaining operator、safe call operator、null-conditional operatorなど様々な名称で呼ばれ、共通した名称はないが、英語圏においてはsafe navigation operatorが広く用いられる。 (ja)
rdfs:label
  • Null条件演算子 (ja)
  • Safe navigation operator (en)
  • 安全导航运算符 (zh)
owl:sameAs
prov:wasDerivedFrom
foaf:isPrimaryTopicOf
is dbo:wikiPageRedirects of
is dbo:wikiPageWikiLink of
is foaf:primaryTopic of
Powered by OpenLink Virtuoso    This material is Open Knowledge     W3C Semantic Web Technology     This material is Open Knowledge    Valid XHTML + RDFa
This content was extracted from Wikipedia and is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License