Post-statement blocks
Macros can receive of, elif, else, except, finally and do blocks (including their different forms such as do with routine parameters) as arguments if called in statement form.
macro performWithUndo(task, undo: untyped) = ...
performWithUndo do:
# multiple-line block of code
# to perform the task
do:
# code to undo it
let num = 12
# a single colon may be used if there is no initial block
match (num mod 3, num mod 5):
of (0, 0):
echo "FizzBuzz"
of (0, _):
echo "Fizz"
of (_, 0):
echo "Buzz"
else:
echo num
当前内容版权归 nim-lang.org 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 nim-lang.org .