Scala演员的问题

时间:2011-12-06 07:03:07

标签: scala actor

为什么这不起作用?

scala> actor { loop { receive {
     | case s:String => s + " :)"
     | }}}
res0: scala.actors.Actor = scala.actors.Actor$$anon$1@2d382988

scala> res0 !? "hello"
... and it hangs here ...

1 个答案:

答案 0 :(得分:6)

尝试对给定的消息做出反应:

actor { loop { receive {
        case s: String => reply(s + " :)")
      }}}