scala不会警告未使用的计算或值 [英] scala does not warn about unused computation or value

查看:188
本文介绍了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不会警告未使用的计算或值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆