Simple question. Can I do this:
object Xyz extends Actor { ... }
or do Actors have to be classes with instances?
Simple question. Can I do this:
object Xyz extends Actor { ... }
or do Actors have to be classes with instances?
The object
keyword is essentially creating an anonymous class and a single instance of that class. So yes, that code will be fine - Xyz
will be a reference to an object that is an Actor.
I would like to recommend the following 'fire and forget' pattern:
Actor.actor { doStuff }
Your operation will run in a separate thread to conclusion.