從一個例子「開頭的斯卡拉」的腳本是:不能在書編譯文件中斯卡拉
import scala.collection.mutable.Map
object ChecksumAccumulator {
private val cache=Map[String,Int]()
def calculate(s: String):Int =
if(cache.contains(s))
cache(s)
else{
val acc = new ChecksumAccumulator
for(c <- s)
acc.add(c.toByte)
val cs=acc.checksum
cache+= (s -> cs)
cs
}
}
,但是,當我試圖編譯該文件 $ scalac ChecksumAccumulator.scala,然後產生一個錯誤,「找不到:輸入ChecksumAccumulator val acc = new ChecksumAccumulator」,有什麼建議?
謝謝,