scala 2.11報錯error: not found: type Application

來源:互聯網
上載者:User

標籤:

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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.