News for hackers. Stuff that matters.
Re:Apple Developer Documentation Is Missing by dtech on Monday October 28, 2019 @10:56AM (#21377522)
This is Javascript/Typescript only, and not really correct.

    a?.b
    a && a.b
will behave differently if a is false or 0 or an otherwise "falsy" value.

It's identical to something similar though

    (a !== undefined && a !== null) ? a : b
Re:Apple Developer Documentation Is Missing by omaranto on Monday October 28, 2019 @02:16PM (#21379855)
That's right, of course. I was just trying to convey the idea. But details matter of course. I was thinking of variables that either contained nil or contained an object with the appropriate field. If that precondition isn't meant you need more robust code like yours.

But also, as another commenter pointed out, there is a distinction between "optional chaining" and "nil coalescing" and I explained (roughly) what optional chaining is.