fork download
  1. import std.c.stdio;
  2.  
  3. int main() {
  4. int[] arr = [1,2,3,4,5];
  5. foreach (ref int x; arr) {
  6. x += 100500;
  7. }
  8. alias ref int ref_int;
  9. foreach (ref_int x; arr) {
  10. printf("%d\n", x);
  11. x -= 100500;
  12. }
  13. printf("---\n");
  14. foreach (int x; arr) {
  15. printf("%d\n", x);
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0.01s 2040KB
stdin
1
2
10
42
11
stdout
100501
100502
100503
100504
100505
---
100501
100502
100503
100504
100505