for_loop_auto.carbon 564 B

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