I'm trying to create a wrapper function for system.scheduler.schedule
. I started by writing the following code:
def every(time : Int) : Unit = {
val system = ActorSystem("timer")
import system.dispatcher
val tickActor = system.actorOf(Props(classOf[TickActor], this))
system.scheduler.schedule(0 milliseconds, time.milliseconds, tickActor, Tick)
}
I'm trying to use it like this:
timer.every(10) {
println("HI")
}
However, I'm getting: Unit does not take parameters
I don't think I've set my function call up correctly to accept the { }, but I don't know how. I don't even know the terminology so I can look it up... I'm really knew to scala.
What do they call something like this and what do I need to do to fix it?