You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apart from convenience, allowing the value of one computation to flow into multiple field initializations is something that requires using multiple chained constructors today.
It would allow something like:
MyAsyncClass() : (_controller, stream) = let c =StreamController<T>() in (c, c.stream);
(where let is from #2703, without that I can get something similar with suitable extension methods).
This is not about patterns in parameters, which we should also have, and which might then apply to initializing formals, like:
Coordinates((this.x, this.y));
The destructuring assignment in the initializer list is more general, because it applies not only to values that are arguments.
The text was updated successfully, but these errors were encountered:
(If we don't want to add one more incremental feature to the limited syntax of initializer lists, an alternative is to move away from them, by either having an entire initializer block, or have an initializer section of the constructor body, where arbitrary statements are allowed, and only this access is restricted. That's a larger feature, but it opens up for much more expressive power during initialization, so you'd no longer have to use an intermediate redirecting or factory constructor just to introduce a local variable. See #2197.)
One more place where a variable is "assigned" is in initializer lists.
Example:
This is also a place where a destructuring assignment makes sense. It would be nice to be able to write the above as:
Apart from convenience, allowing the value of one computation to flow into multiple field initializations is something that requires using multiple chained constructors today.
It would allow something like:
(where
let
is from #2703, without that I can get something similar with suitable extension methods).This is not about patterns in parameters, which we should also have, and which might then apply to initializing formals, like:
The destructuring assignment in the initializer list is more general, because it applies not only to values that are arguments.
The text was updated successfully, but these errors were encountered: