When unpacking tuples in var/let declarations a part of the tuple can now
be discarded using a single underscore.
This commit is contained in:
Dominik Picheta 2015-03-31 00:39:23 +01:00
commit b38eb2e2a8
8 changed files with 39 additions and 6 deletions

View file

@ -0,0 +1,18 @@
discard """
file: "ttupleunpack.nim"
output: ""
exitcode: 0
"""
proc foo(): tuple[x, y, z: int] =
return (4, 2, 3)
var (x, _, y) = foo()
doAssert x == 4
doAssert y == 3
iterator bar(): tuple[x, y, z: int] =
yield (1,2,3)
for x, y, _ in bar():
doAssert x == 1
doAssert y == 2