for_loop.carbon 762 B

123456789101112131415161718192021222324252627282930
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: HALLO WELT 0
  7. // CHECK:STDOUT: HALLO WELT 1
  8. // CHECK:STDOUT: HALLO WELT 2
  9. // CHECK:STDOUT: HALLO WELT 3
  10. // CHECK:STDOUT: HALLO WELT 0
  11. // CHECK:STDOUT: HALLO WELT 1
  12. // CHECK:STDOUT: HALLO WELT 2
  13. // CHECK:STDOUT: HALLO WELT 3
  14. // CHECK:STDOUT: result: 8
  15. package ExplorerTest api;
  16. fn Main() -> i32 {
  17. var ar: [i32; 4] = (0, 1, 2, 3);
  18. var count: i32 = 0;
  19. for (x: i32 in ar) {
  20. Print("HALLO WELT {0}", x);
  21. count = count + 1;
  22. }
  23. for (x: i32 in ar) {
  24. Print("HALLO WELT {0}", x);
  25. count = count + 1;
  26. }
  27. return count;
  28. }