Existential Operator / Null Propagation Operator

Nick Krempel ndkrempel at google.com
Tue Apr 7 17:07:36 UTC 2015

On 7 April 2015 at 18:03, Nick Krempel <ndkrempel at google.com> wrote:

> 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
> accepts.
> 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?

...but thinking about it further, wouldn't you always want the short
circuit semantics? i.e. an option 1 `a?.b.c` is almost certainly a bug?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150407/45d400d3/attachment-0001.html>

More information about the es-discuss mailing list