summary refs log tree commit diff stats
path: root/tests/accept/run/titer3.nim
blob: ab95dd7bdb85f7d126f92f01326753f5156c3fc9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
discard """
  file: "titer3.nim"
  output: "1231"
"""

iterator count1_3: int =
  yield 1
  yield 2
  yield 3

for x in count1_3():
  write(stdout, $x)

# yield inside an iterator, but not in a loop:
iterator iter1(a: openArray[int]): int =
  yield a[0]

var x = [[1, 2, 3], [4, 5, 6]]
for y in iter1(x[0]): write(stdout, $y)

#OUT 1231