www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - immutable arrays and .sort/.reverse

reply simendsjo <simen.endsjo pandavre.com> writes:
 	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]);
Apr 02 2011
parent bearophile <bearophileHUGS lycos.com> writes:
simendsjo:

 	// but I'm allowed to sort in place...
 	a.reverse;
 	assert(a == [3,2,1]);
It's a known bug, already in Bugzilla. Bye, bearophile
Apr 02 2011