struct variable initialized with void.

Lukasz Wrzosek via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 31 08:22:59 PDT 2015


On Tuesday, 31 March 2015 at 15:12:54 UTC, ref2401 wrote:
> struct MyStruct {
> 	// stuff
> }
>
> void main(string[] args) {
> 	MyStruct s1 = void;
> }
>
> Could anyone describe me what this initialization does, please?
> When do I need to use the void initialization?

By default variables are initialized with default value called 
'default initializer'.
i.e default initialize for integer value is 0 (for  more take a 
look at http://dlang.org/type.html)

initializing to void means 'not initialize to default value'.



More information about the Digitalmars-d-learn mailing list