for_loop_auto.carbon 561 B

12345678910111213141516171819202122
  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: result: 4
  11. package ExplorerTest api;
  12. fn Main() -> i32 {
  13. var ar: [i32; 4] = (0, 1, 2, 3);
  14. var count: i32 = 0;
  15. for (x: auto in ar) {
  16. Print("HALLO WELT {0}", x);
  17. count = count + 1;
  18. }
  19. return count;
  20. }