Singleton Scala Actor?

Simple question. Can i do this:

object Xyz extends Actor { ... }

or should actors be instance classes?

+5
source share
3 answers

The keyword objectessentially creates an anonymous class and one instance of this class. So yes, this code will be in order - it Xyzwill be a link to an object that is an Actor.

+6
source

Object extension Actorworks fine.

Did you forget the startactor? (This is a mistake I made initially)

object Xyz extends Actor {
    start

    ...
}
+12
source

" ":

Actor.actor {doStuff}

.

+2

All Articles