scala不会警告未使用的计算或值

编程入门 行业动态 更新时间:2024-10-14 14:16:54
本文介绍了scala不会警告未使用的计算或值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有这个小scala例子:

I have this little scala example:

object Test { def add(x: Int, y: Int) = { val z = x - y x match { case 0 => 0 - y case 1 => 1 - y case _ => x - y } x + y } def main(args: Array[String]) { println(add(5, 6)) } }

我觉得scala应该警告'z'和'x match ...'未使用。我没有注意到任何编译器选项,以打开更多的警告。我使用scala 2.10.1。

I feel that scala should warn about 'z' and the 'x match ...' being unused. I did not notice any compiler options to turn on more warnings. I'm using scala 2.10.1.

想法?谢谢!

推荐答案

正如你可以看到此处,未使用警告将在scala的下一版本2.11中引入。

As you can see here, "unused" warnings will be introduced in the next version of scala, 2.11.

警告未使用

Warn about unused private / local terms and types, and unused imports, under -Xlint

您可以使用最后一个里程碑来尝试它们。

You can try them using the last milestone.

更多推荐

scala不会警告未使用的计算或值

本文发布于:2023-11-27 13:10:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638208.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:scala

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!