Reputation: 31
How to return a value from receive method in scala actor model, when all the variables are immutable.
title =
receive{
case title: String => title
}
when i tried the above it says found Unit.
Is it possible to return a value from within receive.
Upvotes: 0
Views: 327
Reputation: 38045
Your code is fine. Error is somewhere else. Tested in scala 2.9.3
with -Yrepl-sync
option:
scala> import scala.actors.Actor._
import scala.actors.Actor._
scala> self ! "test"
scala> val title = receive { case title: String => title }
title: String = test
Upvotes: 3