书中的代码:
object NameResolver extends Actor{
import java.net.{InetAddress, UnknownHostException}
def act(){
react{
case(name:String, actor:Actor) =>
actor ! getIp(name)
act()
case "EXIT" =>
println("Name resolver is exiting.")//quit
case msg =>
println("Unhandled message: "+msg)
act()
}
}
def getIp(name:String):Option[InetAddress]={
try{
Some(InetAddress.getByName(name))
} catch {
case _ : UnknownHostException => None
}
}
}
口译行:
NameResolver ! ("http://stackoverflow.com", self)
但我得到了错误:
scala> NameResolver ! ("http://stackoverflow.com", self)
<console>:8: error: too many arguments for method !: (msg: Any)Unit
NameResolver ! ("http://stackoverflow.com", self)
根据书,它应该工作。我从书中复制的代码中是否存在会导致异常的错误?