April 02, 2011 immutable arrays and .sort/.reverse | ||||
---|---|---|---|---|
| ||||
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]); |
Copyright © 1999-2021 by the D Language Foundation