Skip to content

Collection expressions - spread operator Symbol question #7686

Closed Answered by CyrusNajmabadi
RNabla asked this question in Q&A
Discussion options

You must be logged in to vote

While the concept is familiar, syntax seems unfamiliar. The first question that came to my mind - why not 3 dots like it's in JavaScript, Dart and even Java.

This is covered in the design doc :)

Specifically, we already use .. to represent a set of elements when deconstructing. Like so:

if (x is [var start, .. var middle, var end])

We also want construction and deconstruction to be mirrored. So the form that allows that is:

M([start, .. middle, end]);

syntax seems unfamiliar.

Syntax familiarity comes very quickly to developers.

I feel like using something familiar (for developers coming from other languages) would be a better design choice.

We do consider that. And all other things …

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@RNabla
Comment options

@CyrusNajmabadi
Comment options

Answer selected by CyrusNajmabadi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants