Consider allowing Method definitions with a void return type, particularly Constructors, without a body by ending them with a semicolon #9149
Replies: 4 comments
-
The presence of an access modifier would qualify it as a method definition avoiding any ambiguity. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Partial methods already support this syntax and extend it to Constructors as well under the assumption that the method body for the latter is optional. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing as dupe |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
Consider allowing Method definitions with a void return type, particularly Constructors, without a body by ending them with a semicolon.
With the introduction of Records and Primary Constructors, it is now easy to define a type in a single line ending with a semicolon.
But sometimes, there is a need to define additional constructors either to invoke a constructor initializer or pass the parameter values to the base constructor without any additional work involved.
However, these types of methods require a pair of curly braces to be recognized as a method, rather than ending with a semicolon which would otherwise be considered a valid definition.
Beta Was this translation helpful? Give feedback.
All reactions