[Proposal] Spread members into anonymous object creation #10039
Unanswered
iikuzmychov
asked this question in
Language Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Allow spreading members of an existing object into anonymous object creation.
Equivalent to writing out the included members explicitly:
Motivation
Today the options are either nesting:
or repeating all members manually:
The first changes the shape. The second is verbose and brittle.
Proposal
Support spread syntax in anonymous object creation:
Equivalent to:
Semantics
Example:
If
bookalso containsTitle, this is a compile-time error.Open questions
..obj,...obj, orobj.*?Beta Was this translation helpful? Give feedback.
All reactions