The daily D riddle

Mike Franklin slavo5150 at yahoo.com
Sun Jan 28 06:33:17 UTC 2018


On Sunday, 28 January 2018 at 06:25:51 UTC, Shachar Shemesh wrote:
> What will the following code print? Do not use the compiler:
>
> import std.stdio;
>
> struct A {
> 	int a = 1;
>
> 	void initialize() {
> 		a = a.init;
> 	}
> }
>
> void main() {
> 	A a;
> 	a.initialize();
>
> 	writeln(a.a);
> }
>
> I find this behavior unexpected.

Works exactly as I predicted.


More information about the Digitalmars-d mailing list