rfc:null-propagation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
rfc:null-propagation [2018/01/23 09:17] daverandomrfc:null-propagation [2018/01/23 10:14] daverandom
Line 42: Line 42:
  
 <code php> <code php>
 +$foo = new Foo(null);
 $result = $foo->getBar()?->method(); $result = $foo->getBar()?->method();
 +var_dump($result); // NULL
 </code> </code>
 +
 +This operator does not suppress any errors that are generated by the left hand side of the expression, it only short-circuits the right hand side.
  
 ===== Examples in other languages ===== ===== Examples in other languages =====
 +  * [[https://docs.hhvm.com/hack/operators/null-safe|Hack]]
   * [[https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators|C# and Visual Basic]]   * [[https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/operators/null-conditional-operators|C# and Visual Basic]]
-  * [[https://github.com/tc39/proposal-optional-chaining|ECMA Script]] (Stage 1 proposal)+  * [[https://github.com/tc39/proposal-optional-chaining|ECMAScript]] (Stage 1 proposal)
   * [[http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/|Ruby]]   * [[http://mitrev.net/ruby/2015/11/13/the-operator-in-ruby/|Ruby]]
  
rfc/null-propagation.txt · Last modified: 2018/01/29 16:33 by levim