The daily D riddle

Shachar Shemesh shachar at weka.io
Sun Jan 28 06:25:51 UTC 2018


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.


More information about the Digitalmars-d mailing list