这里的 nim lang教程说 -
没有任何 return 语句且不使用特殊结果变量的过程返回其最后一个表达式的值。
为什么我的echo res打印 0 ?我不应该期望a mod b返回最后一个语句(= 3) 吗?
proc divmod(a, b: int; res, remainder: var int): int =
res = a div b
remainder = a mod b
var
x, y: int
let res: int = divmod(8, 5, x, y) # modifies x and y
echo res
Run Code Online (Sandbox Code Playgroud) nim-lang ×1