標籤:
FROM: http://j-q-j.org/scala/scala-2-11-application-error.html
這兩天學習scala,官網下載的最新版本2.11,書用的是《Programming in scala》,看到類和對象,這一章最後一段代碼
| 12345 |
import ChecksumAccumulator.calculateobject FallWinterSpringSummer extends Application { for (season <- List("fall", "winter", "spring")) println( season + ": " calculate(season))} |
scalac FallWinterSpringSummer.scala報錯如下
| 1 |
error: not found: type Application |
尋找scala官方api,發現內建了Application類的,不知道哪裡出錯了,書的範例程式碼照樣編譯出錯。
百度搜尋未果,FQgoogle好不容易才發現結果,最後發現stackoverflow大神的解釋
http://stackoverflow.com/questions/26176509/why-does-2-11-1-fail-with-error-not-found-type-application
Application has been deprecated from scala 2.9, probably it has been deleted in scala 2.11 (it still exists in scala 2.10) even though at the moment I can‘t find proofs for that, use App instead.
Proof found, this is the scala 2.11 branch on github which has only an App.scala and this is the 2.10which has App.scala and Application.scala with a deprecated warning.
scala 2.9以後的版本廢棄了Application而是啟用了App類,修正後代碼如下
| 12345 |
import ChecksumAccumulator.calculateobject FallWinterSpringSummer extends App { for (season <- List("fall", "winter", "spring")) println( season + ": " calculate(season))} |
還是不要趕時髦的好,乖乖下載個2.9繼續搞。
scala 2.11報錯error: not found: type Application