首页 > 解决方案 > 如何忽略 Nim 中过程的结果

问题描述

根据标题,假设我有以下内容:

proc squared(n: int64): int64 = n * n

现在让我们假设我想调用该过程squared,但我对结果不感兴趣。

如果我只写:

squared(15)

我收到一个错误:

Error: expression 'squared(15)' is of type 'int64' and has to be discarded

我知道这种类型的代码是一种不好的做法,我应该明确地忽略结果。 因此,我如何明确忽略结果?

标签: nim-lang

解决方案


写吧

discard squared(15)

推荐阅读