'return' for first class iterators
This commit is contained in:
parent
dd9ad9e497
commit
2591ac0ada
6 changed files with 80 additions and 21 deletions
20
tests/run/titer9.nim
Normal file
20
tests/run/titer9.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
discard """
|
||||
output: '''5
|
||||
14
|
||||
0'''
|
||||
"""
|
||||
|
||||
iterator count(x: int, skip: bool): int {.closure.} =
|
||||
if skip: return x+10
|
||||
else: yield x+1
|
||||
|
||||
if skip: return x+10
|
||||
else: yield x+2
|
||||
|
||||
proc takeProc(x: iterator (x: int, skip: bool): int) =
|
||||
echo x(4, false)
|
||||
echo x(4, true)
|
||||
echo x(4, false)
|
||||
|
||||
takeProc(count)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue