小编svb*_*svb的帖子

来自 proc 的隐式返回值

这里的 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

2
推荐指数
1
解决办法
86
查看次数

标签 统计

nim-lang ×1