mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
18 lines
444 B
Text
18 lines
444 B
Text
Shortened method syntax can now be used in constructors
|
|
|
|
This used to raise an error (cannot return expression from constructor), but is now supported:
|
|
|
|
---
|
|
struct Number
|
|
{
|
|
int x;
|
|
|
|
void vf(int);
|
|
this(int x) => vf(x);
|
|
this(float x) => this(cast(int) x);
|
|
}
|
|
---
|
|
|
|
The expression body must be a `this`/`super` call or have type `void`.
|
|
|
|
Postblits and destructors already supported shortened method syntax because they return `void`.
|