On 10 July 2012 10:47, Russell Leggett <[email protected]> wrote:
> Another thing that I was also thinking is that it might look a little
> nicer if the ? was a post-fix instead of a pre-fix.
>
> let {first, last, company?} = contact;
>
> I might be missing why this wouldn't work out, but it aesthetically just
> looks right to me. It looks like the regex operator, and is also obviously
> the position it would be in english.
>
Even parsing issues aside, I don't like postfix better. It is easier to
miss, especially if ? was possible on patterns, not just properties.
Consider:
let {the, that: {x, y}, those, theirs: {what, why}, thus}? =
callSomething()
How easy is it to miss the final '?' when looking for the binding of 'x'?
But even on longish property names it can be a tad too easy to overlook:
let {what, why, whatTheHeckIsGoingOn?} = callSomething()
/Andreas
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss