[
]
automatic parameter brackets
#4247
Labels
feature
Proposed language feature that solves one or more problems
[
]
automatic parameter brackets
#4247
Optional positional parameters coexisting with named parameters would be great by any means, and we already have some well-thought-out feature proposals:
This issue presents a slight variation on those ideas.
Maybe the compiler could "automatically add the square brackets" to as many parameters as it can, starting from the rightmost positional parameter. For example:
That compile-time error would be consistent with e.g. Python:
If this were implemented, named arguments could follow a similar pattern: instead of typing
required
, a named argument would be required if it's non-nullable and lacks a default value. (A nullable parameter such as a button's onPressed could be given a@required
annotation if desired.)Essentially, this is identical to the proposal in #2232 but would also allow for parameters with default values, since I think it's really cool that the IDE shows this info when your mouse is hovering on a constructor.
The text was updated successfully, but these errors were encountered: