-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Labels
brevityA feature whose purpose is to enable concise syntax, typically expressible already in a longer formA feature whose purpose is to enable concise syntax, typically expressible already in a longer formsmall-featureA small feature which is relatively cheap to implement.A small feature which is relatively cheap to implement.
Description
This is the tracking issue for the Private Named Parameters proposal.
The proposal makes it easier to initialize and declare private instance fields using named constructor parameters. It addresses #2509 and turns code like this:
class House {
int? _windows;
int? _bedrooms;
int? _swimmingPools;
House({
int? windows,
int? bedrooms,
int? swimmingPools,
}) : _windows = windows,
_bedrooms = bedrooms,
_swimmingPools = swimmingPools;
}
Into this:
class House {
int? _windows;
int? _bedrooms;
int? _swimmingPools;
House({this._windows, this._bedrooms, this._swimmingPools});
}
The proposal harmonizes with (and in a couple of places mentions) the primary constructors proposal. When combined with that proposal, the above example becomes:
class House({
var int? _windows,
var int? _bedrooms,
var int? _swimmingPools,
});
Without this proposal, the example here wouldn't be able to use a primary constructor at all without giving up either privacy on the fields or named parameters in the constructor.
srawlins, julemand101, alex-medinsh, xvrh, lntls and 15 more
Metadata
Metadata
Assignees
Labels
brevityA feature whose purpose is to enable concise syntax, typically expressible already in a longer formA feature whose purpose is to enable concise syntax, typically expressible already in a longer formsmall-featureA small feature which is relatively cheap to implement.A small feature which is relatively cheap to implement.