class variable initialization

NonNull non-null at use.startmail.com
Sat Apr 15 16:06:50 UTC 2023


On Saturday, 15 April 2023 at 15:47:40 UTC, Steven Schveighoffer 
wrote:
> You can construct objects at compile time.
>
> If I understand your question properly:
>
> ```d
> struct Wrapper
> {
>    Object x = new Object();
>    alias x this;
> }
>
> void foo(Object o)
> {
>    assert(o !is null);
> }
>
> void main()
> {
>    Wrapper w;
>    foo(w);
> }
> ```
>
> -Steve

Amazing, was this always so?





More information about the Digitalmars-d-learn mailing list