Can't assign to static array in ctor?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Apr 9 11:47:06 PDT 2012


What's the reason the following code doesn't compile?

	struct S {
		const(int)[4] data;
		this(const(int)[4] d) {
			data = d;	// this is line 4
		}
	}

	void main() {
		S s;
	}

Compiler error:

	test.d(4): Error: slice this.data[] is not mutable

Shouldn't the assignment be valid in the ctor?


T

-- 
MSDOS = MicroSoft's Denial Of Service


More information about the Digitalmars-d mailing list