Existential Operator / Null Propagation Operator
ndkrempel at google.com
Tue Apr 7 17:03:47 UTC 2015
On 6 April 2015 at 20:01, Jordan Harband <ljharb at gmail.com> wrote:
> If I want the short circuit in option 1, I'd do `a?.b?.c` to indicate
> that, whereas in option 2 if I don't want the short circuit, I'm forced to
> use separate variables.
Worth noting that an option 1 `a?.b?.c` differs from an option 2 `a?.b.c`
in that the latter is effectively asserting that if a != null then its b
property is also != null, whereas the former is more lenient in what it
Also you are not forced to use separate variables in option 2, you can just
use parentheses: `(a?.b).c` - hence the whole discussion of lack of
transitivity (more correctly, associativity) for option 2. Or did I
misunderstand what you're trying to achieve?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss