Reputation: 2154
I'm working on eclipse under ubuntu 12.04 with scala 2.10 and Akka 2.2.1.
abstract class Node extends Actor {
var n : Array[Node] // def n
//..... I do not def receive here
}
class FNode extends Node {
def receive = {
case message => for(i <- 0 until n.size)
n(i) ! message // n is array. send message to all elements in n
// ....
}
}
Now, eclipse always reports
value ! is not a member of Node.
I have no idea how to fix. I waste more than 3 hours on this. I have done what I can do, but I still can not solve it. Thanks !
Upvotes: 1
Views: 78
Reputation: 6543
I believe the problem is that ! is defined for the ActorRef type, not the Actor type which your Node type extends.
Upvotes: 1
Reputation: 3722
You can't send messages to an Actor
, but only to an ActorRef
. Change n
to an Array[ActorRef]
and it should work.
By the way, you can iterate collections and arrays easier and possibly more efficient, e.g.
n foreach (ref => ref ! message)
Upvotes: 4