我最近更新到 Eclipse Juno,它也将我的 Scala 更新到了 2.10。我知道 Actor 现在已被弃用,但我仍然想使用它们。scala-actors.jar 和 scala-actors-migration.jar 是我的 Eclipse 构建路径的一部分,但是,对于导入,我得到“对象演员不是包 scala 的成员”。任何将 scala 库重新添加到项目的尝试都失败了,也没有修复它。
带有 Eclipse Juno 和 Scala 2.10 的 Mac OS X Lion。
一些代码(标记错误XXX):
import scala.actors.Actor XXX actors not found in scala
import scala.actors.Actor._ XXX actors not found in scala
class Solver() extends Actor { XXX Actor not found
def act() {
// Read file
val source = io.Source.fromFile("src/labyrinth.txt", "utf-8")
val lines = source.getLines.toList
source.close()
// Fill multidimensional array
var labyrinth = Array.ofDim[Cell](lines.length, lines.apply(0).length)
for (i <- 0 until lines.length) { // each line
for (j <- 0 until lines.apply(0).length) { // each column
labyrinth(i)(j) = new Cell(lines.apply(i).toList.apply(j)) // Fill array cell with character
}
}
// Search for start
for (k <- 0 until labyrinth(0).length) {
if (labyrinth(0)(k).character.toString() == "?") {
val start = new CheckCell(labyrinth, Array((1, k)), this).start // Kick off search
while (true) {
receive { XXX receive not found
case FoundSolution => XXX FoundSolution not found
Console.println("Pong: stop")
start ! Stop XXX Stop not found
exit()
}
}
}
}
}
}