I dun a DIP, possibly the best DIP ever
Fynn Schröder
fynnos at live.com
Sun Apr 26 11:18:02 UTC 2020
On Sunday, 26 April 2020 at 11:13:25 UTC, Sebastiaan Koppe wrote:
> On Sunday, 26 April 2020 at 10:20:49 UTC, Walter Bright wrote:
>> On 4/24/2020 6:31 PM, Manu wrote:
>>> Javascript also uses `...` for something similar-ish, so the
>>> web guys should find it familiar too.
>>
>> I don't remember Javascript doing that, though it's been 20
>> years since I worked on the JS compiler. Maybe it's a later
>> addition.
>
> It is a recent addition, ES6 I believe.
>
> They use it in destructuring:
>
> ```
> const {a, b, rest...} = {a:1, b:2, c:3, d:4}; // rest == {c:3,
> d:4}
> ```
>
> and in expanding arrays
>
> ```
> function foo(a,b) {}
> const ab = [1,2];
> foo(...ab);
> ```
> snip
JavaScript uses ... as the spread operator. It expands an
expression in places where multiple arguments are expected. Since
JavaScript does not have tuples, arrays are used instead.
D's equivalent for JS ... operator on function parameters would
be Tuple.expand
More information about the Digitalmars-d
mailing list