I';我对使用2.7.7-Main$$anon$1$$anonfun$1$$anonfun$apply$2的scala脚本有问题
这是我在一本书中使用的代码I';我对使用2.7.7-Main$$anon$1$$anonfun$1$$anonfun$apply$2的scala脚本有问题,scala,actor,Scala,Actor,这是我在一本书中使用的代码 import scala.actors.Actor._ val countActor = actor { loop { react { case "how many?" => { println("I've got " + mailboxSize.toString + " messages in my mailbox.") } } } } countActor ! 1 countActor !
import scala.actors.Actor._
val countActor = actor {
loop {
react {
case "how many?" => {
println("I've got " + mailboxSize.toString + " messages in my mailbox.")
}
}
}
}
countActor ! 1
countActor ! 2
countActor ! 3
countActor ! "how many?"
countActor ! "how many?"
countActor ! 4
countActor ! "how many?"
错误
java.lang.NoClassDefFoundError:Main$$anon$1$$anonfun$1$$anonfun$apply$2我猜您只是使用scala执行,而不是编译。如果编译该脚本(并将其包装在Application trait singleton对象中),则该脚本确实有效: 当我编译它时,我会得到以下文件:
- ActorTest$$anonfun$1$$anonfun$apply$2$$anonfun$apply$1.class
- ActorTest$$anonfun$1$$anonfun$apply$2.class
- ActorTest$$anonfun$1.class
- ActorTest$.class
- ActorTest.class
希望有帮助。啊!你知道……是的谢谢。不要将演员与
应用程序混用。
ricoeur:~ tom$ scala -cp . ActorTest
I've got 6 messages in my mailbox.
I've got 5 messages in my mailbox.
I've got 4 messages in my mailbox.
^C