diff options
Diffstat (limited to 'tests/accept/compile/titer2.nim')
-rw-r--r-- | tests/accept/compile/titer2.nim | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/accept/compile/titer2.nim b/tests/accept/compile/titer2.nim index 19c7298b0..dab2713e8 100644 --- a/tests/accept/compile/titer2.nim +++ b/tests/accept/compile/titer2.nim @@ -19,15 +19,15 @@ iterator mycountup(a, b: int): int = yield res inc(res) -iterator pairs*[A, B](t: TTable[A, B]): tuple[key: A, val: B] = - ## iterates over any (key, value) pair in the table `t`. - var h = 0 - while h <= high(t.data): - var k = t.data[h].key - if t.data[h].slot == seFilled: yield (k, t.data[h].val) - inc(h) - - when false: +when true: + iterator pairs*[A, B](t: TTable[A, B]): tuple[key: A, val: B] = + ## iterates over any (key, value) pair in the table `t`. + for h in mycountup(0, high(t.data)): + var k = t.data[h].key + if t.data[h].slot == seFilled: yield (k, t.data[h].val) +else: + iterator pairs*(t: TTable[int, string]): tuple[key: int, val: string] = + ## iterates over any (key, value) pair in the table `t`. for h in mycountup(0, high(t.data)): var k = t.data[h].key if t.data[h].slot == seFilled: yield (k, t.data[h].val) |