Designated initializers to function argument
Steven Schveighoffer
schveiguy at gmail.com
Tue Jul 11 17:43:43 UTC 2023
On 7/11/23 11:22 AM, Ki Rill wrote:
> On Tuesday, 11 July 2023 at 15:16:54 UTC, Ki Rill wrote:
>> ```D
>>
>> // or this
>> apply(Appearance(color: BLACK, strokeWidth: 4)); // other fields are
>> default initialized: strokeOpacity, fillOpacity, etc...
>>
>> ```
>
> Ok, this works with DMD v2.103, but does not work with an older version
> (I had ldc2 installed based on DMD v2.98).
Yes, I was going to reply that v 2.103 has added (stealthily) named
parameters *as a partial implementation*. Included in this is struct
initializers, and constructors and functions that are *not* templates.
If you are willing to use DMD 2.103 and above, you should be good.
-Steve
More information about the Digitalmars-d-learn
mailing list