nim-lang - 如何忽略 Nim 中过程的结果
问题描述
根据标题,假设我有以下内容:
proc squared(n: int64): int64 = n * n
现在让我们假设我想调用该过程squared
,但我对结果不感兴趣。
如果我只写:
squared(15)
我收到一个错误:
Error: expression 'squared(15)' is of type 'int64' and has to be discarded
我知道这种类型的代码是一种不好的做法,我应该明确地忽略结果。 因此,我如何明确忽略结果?
解决方案
写吧
discard squared(15)
推荐阅读
- sorting - 去 sort.IntSlice() 实现
- c# - Application Insights 开发人员模式在 ASP.NET Core 3.1 中不起作用
- machine-learning - 使用 SMOTE 过采样从 y_train 中删除标签类别
- c# - 如何从项目列表中生成多个表单?
- google-cloud-dataflow - GCP 数据流 - 吞吐量逐渐减慢,工作人员未充分利用
- spring-boot - 尝试在 Java Spring Boot 中从 H2 数据库中获取相关实体
- ansible - 单个项目和项目列表的循环和 with_items 行为之间的区别
- html - 将css文件链接到html文件时的根目录
- python - OpenCV - 从二维图像点正确恢复姿势和地标位置
- r - 反转变量列表的值