Scala 是否可以在脚本内提供类型检查?
有谁知道是否有办法在 Scala 脚本中进行类型检查?当我编写简短的脚本时,我觉得我失去了很多 Scala 类型检查的优势(即在编写代码时捕获错误,而不是在尝试编译时捕获错误)。
Does anyone know if there's a way to do have type checking in scripts for Scala? When I'm writing short scripts, I feel I lose a lot of the strength of Scala's typechecking (i.e. catching errors when writing code, rather than when I try and compile).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这个奇妙的迈尔斯·萨宾回答;感谢 tenshi 指出了这一点。您想要运行
成功由以下输出表示:
我同意如果有一种更用户友好的方式可用(
-Y
编译器选项非常神秘,并且可能会更改,恕不另行通知) ;成功消息掩盖了该解决方案的“hackishness”)。但目前,您应该能够使用它。希望我有所帮助。
See this fantastic answer by Miles Sabin; thanks to tenshi for pointing this out. You want to run
Success is indicated by this output:
I agree that it would be nice if a more user-friendly way were available (the
-Y
compiler options are quite arcane, and subject to change without notice; the success message belies the "hackishness" of this solution). But for the time being, you should be able to use this.Hope I've been helpful.
如果您使用 Ecplise Scala IDE,它支持增量编译,就像 JDT 对 Java 所做的那样。这样,您就可以在行驶时遇到红灯。
If you use the Ecplise Scala IDE it supports incremental compilation, just like the JDT does for Java. This way, you get your red lights as you go.