How to change DList elements by means of foreach?
Alexandr Druzhinin
drug2004 at bk.ru
Mon Sep 10 04:18:58 PDT 2012
I have code:
import std.container;
int main() {
// array
int[] array = [0];
foreach(ref value; array) {
value += 50;
assert(value == 50);
}
foreach(value; array) {
assert(value == 50);
}
// double-linked list;
DList!int dlist;
dlist.insertFront(0);
foreach(ref value; dlist) {
value += 50;
assert(value == 50);
}
foreach(value; dlist) {
assert(value == 50); // Why do I have assertion failure here?
}
}
How to change the value of elements of DList?
More information about the Digitalmars-d-learn
mailing list