這個非常簡單的工作表內容表明瞭問題:從上面的表內容斯卡拉工作不IntelliJ IDEA的評估對象2016.2
object Test {
println("This does not print!")
add(5, 6)
}
println("This however prints!")
add(5, 6)
def add(a: Int, b: Int): Int = a + b
結果是:
defined module Test
This however prints!
res0: Unit =()
res1: Int = 11
add: add[](val a: Int,val b: Int) => Int
基於JetBrains official website Scala Worksheets example和所有其他我發現的可靠資源(如Martin Odresky's own examples in Functional Programming in Scala course),我期望執行object Test
的內容。我的軟件是:
- OS X埃爾卡皮坦
- IntelliJ IDEA的2016.2
- SBT插件1.8.0
- SBT版本0.13.12
- 的Scala插件2016年2月1日
- 斯卡拉2.11版.8
'我期待對象Test的內容執行'我不希望它執行。工作表是花哨的回報。我永遠不會期望repl做到這一點 – Jatin
那麼,我發現的所有例子(包括JetBrains網站本身的頁面)都顯示工作表的工作原理與此類似。我已將它添加到我的答案中。 – ddinchev