immutable arrays and .sort/.reverse

simendsjo simen.endsjo at pandavre.com
Sat Apr 2 07:33:53 PDT 2011


 	immutable(int[]) a = [1,2,3];
	assert(!is(typeof({a[0] = 0;}))); // cannot change elements
	assert(!is(typeof({a = [1,1,1];}))); // cannot rebind

	// but I'm allowed to sort in place...
	a.reverse;
	assert(a == [3,2,1]);


More information about the Digitalmars-d-learn mailing list