mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 05:00:16 +03:00
Allow shortened method syntax for constructors
This commit is contained in:
parent
f28b1a0f0a
commit
56eb579a45
3 changed files with 32 additions and 1 deletions
15
changelog/dmd.shortened-method-constructor.dd
Normal file
15
changelog/dmd.shortened-method-constructor.dd
Normal file
|
@ -0,0 +1,15 @@
|
|||
Shortened method syntax can now be used in constructors
|
||||
|
||||
This used to raise an error "cannot return expression from constructor", but it's now supported:
|
||||
|
||||
---
|
||||
struct Number
|
||||
{
|
||||
int x;
|
||||
|
||||
this(int x) => this.x = x;
|
||||
this(float x) => this(cast(int) x);
|
||||
}
|
||||
---
|
||||
|
||||
Postblits and destructors already supported shortened method syntax because they return `void`.
|
Loading…
Add table
Add a link
Reference in a new issue