comparison tests/mini/foreach11.d @ 1185:8baf611f0009

Fix nested references to 'ref' foreach variables. These "walk around" the array being iterated over, so they're a bit trickier than other variables to get right.
author Frits van Bommel <fvbommel wxs.nl>
date Wed, 01 Apr 2009 00:01:44 +0200
parents
children
comparison
equal deleted inserted replaced
1183:df386fd4030e 1185:8baf611f0009
1 module foreach11;
2
3 extern(C) int printf(char*, ...);
4
5 void main() {
6 char* last = null;
7 printf("The addresses should remain constant:\n");
8 foreach (c; "bar") {
9 auto a = {
10 printf("%x '%c'\n", c, c);
11 printf("ptr = %p\n", &c);
12 if (last)
13 assert(last == &c);
14 };
15 a();
16 last = &c;
17 }
18 }