Scala IntelliJ中错误的顶级声明声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37206205/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
wrong top statement declaration in scala IntelliJ
提问by Scana
I have the following warning, could you explain what does it mean, and how I can correct the code to get rid of the warning?
我有以下警告,您能解释一下这是什么意思,以及如何更正代码以消除警告?


采纳答案by Julien Lafont
You forgot the return type in your method definition. Therefore the body is not well parsed.
您忘记了方法定义中的返回类型。因此身体没有被很好地解析。
For example:
例如:
def scaleMap(file: File, key: String): Map[String Int] = { ... }
If you don't know the correct return type immediately, you can just ignore the returnpart of the method definition. The return type will then be inferred by the compiler.
如果您不立即知道正确的返回类型,您可以忽略return方法定义的部分。然后编译器会推断返回类型。
def scaleMap(file: File, key: String) = { ... }

