toString contains null for struct with function/method

number putimalitze at gmx.de
Sun Apr 8 15:04:49 UTC 2018


the write() shows a 'null' if the struct has a function/method. 
why is that?
```
import std.stdio;

void main()
{
	struct S
	{
		int i;
	}
	S s;
	writeln(s);                // S(0)
	writeln(typeid(s).sizeof); // 8
	
	struct S2
	{
		int i;
		this(this){}
	}
	S2 s2;
	import std.conv: to;
	writeln(s2);                // S2(0, null)
	writeln(typeid(s2).sizeof); // 8
}
```


More information about the Digitalmars-d-learn mailing list