Abh*_*kar 1 scala postfix-notation deprecation-warning
我的代码:
val exitStatus = url #> outfile !
scala.sys.process:
new URL("http://www.scala-lang.org/") #> new File("scala-lang.html") !
警告:
postfix operator ! should be enabled
[warn] by making the implicit value scala.language.postfixOps visible.
[warn] This can be achieved by adding the import clause 'import scala.language.postfixOps'
[warn] or by setting the compiler option -language:postfixOps.
[warn] See the Scaladoc for value scala.language.postfixOps for a discussion
[warn] why the feature should be explicitly enabled.
[warn] val exitStatus = url #> outfile !
[warn] ^
[warn] one warning found
Run Code Online (Sandbox Code Playgroud)
跆拳道???
保持冷静并遵循警告.
import scala.language.postfixOps
...
val exitStatus = url #> outfile !
...
Run Code Online (Sandbox Code Playgroud)
并且......没有警告!:)
这样做的原因是,Scala的新手不会意外地使用这些并最终对语法更加困惑.我不确定我同意这个理由,但它似乎与我的同事/朋友合作,所以肯定有一些东西.
顺便在这里是Scaladoc页,详细描述了所有这些.您也可以将它们作为编译器标志或通过启用build.sbt.
-language:dynamics # Allow direct or indirect subclasses of scala.Dynamic
-language:existential # Existential types (besides wildcard types) can be written and inferred
-language:experimental.macros # Allow macro defintion (besides implementation and application)
-language:higherKinds # Allow higher-kinded types
-language:implicitConversions # Allow definition of implicit functions called views
-language:postfixOps # Allow postfix operator notation, such as `1 to 10 toList'
-language:reflectiveCalls # Allow reflective access to members of structural types
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2471 次 |
| 最近记录: |