Refutable pattern

Andreas Rossberg rossberg at
Fri Feb 1 09:21:41 PST 2013

On 1 February 2013 10:56, Axel Rauschmayer <axel at> wrote:
> Beautiful.
> What do question marks in value (as opposed to key) positions mean?
> Example: { a: x? }

Not much: a plain identifier 'x' is always matches anyway, i.e. is
already irrefutable, so wrapping a '?' around it does not have any
effect (it's like writing "if (true)" or whatever). I removed the
redundant example.

> How does this work grammatically (ternary operator…)?

That still has to be worked out. I'd actually prefer a prefixed ?,
since it is quite easy to overlook a postfix one trailing a longish
pattern when reading code. But that may be more difficult to reconcile
with the existing syntax.


More information about the es-discuss mailing list