Suggestion: final struct initializers

Jacob Carlborg doob at me.com
Fri Dec 4 15:25:13 UTC 2020


On 2020-12-04 07:19, Mr T. wrote:
> Hello. Got a suggestion, not even a request: exhaustive struct 
> initializers.
> 
> Like this:
> 
> ------------------------
> struct Box {
>      int x;
>      int y;
> }
> 
> void foo() {
>      Box box = {x: 3};              // ok
>      Box box = final {x: 3};        // error: y not initialized
>      Box box = final {x: 3, y: 7};  // ok
> }
> ------------------------
> 
> I'd appreciate this. What do you think?

You can just use a constructor to achieve the same thing.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list