Error: cannot modify struct arr[0] MyStruct with immutable members

ref2401 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 11 06:37:26 PDT 2015


struct MyStruct {
	this(int a, int b) {
		this.a = a;
		this.b = b;
	}

	immutable int a;
	immutable int b;
}

void main(string[] args) {
	MyStruct[] arr = new MyStruct[3];

	arr[0] = MyStruct(5, 7);
}	

Why does it happen?


More information about the Digitalmars-d-learn mailing list