mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-05 04:27:44 +00:00
When unpacking tuples in var/let declarations a part of the tuple can now be discarded using a single underscore.
19 lines
292 B
Nim
19 lines
292 B
Nim
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
|