On Mar 17, 2013, at 1:17 , Allen Wirfs-Brock <[email protected]> wrote:
> If you need to do arity analysis of parameter but also what to apply default
> values, destructuring, etc I would do the following:
>
> Instead of
> function ([a,b], c,d=5, ...rest) {...}
> do
> function (...args) {
> if (args.length <3) throw Error("too few arguments"); // (*)
> let [[a,b], c,d=5, ...rest] = args; //probably need some ?'s in
> there, but I haven't internalized the details of the new pattern matching yet.
> }
Nice, I forgot about rest parameters. You’d still get an exception from
matching if you omitted line (*), right?
Shame that we can’t have the destructuring semantics for parameters.
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss