Set initializer syntax

I wonder if that idea was discussed, wasn't able to find.

There's short syntax for initializing Sets in Python. It seems to organically match syntax for Arrays and Objects:

let mySet = {'foo', 'bar', 'baz'} // = new Set(['foo', 'bar', 'baz'])

It even displays so in console:

Set(3) {'a', 'b', 'c'}

Just leaving it here for now, since I can't imagine how's that possible to promote/develop this idea.
Are there some advantages/drawbacks/stoppers?

Well, that specific syntax would have issues.

const x = { a, b }

That already means something - it means create an object with two keys, "a" and "b", using the local variables a and b.

But, there's certainly other syntaxes that could be used.

I don't know of any prior discussion around this, but I bet there's something somewhere. It'll be interesting to hear what others think about it.

1 Like

Prior discussions:

2 Likes