box-o-sand/scala/official-tutorial/Timer.scala

16 lines
303 B
Scala

object Timer {
def oncePerSecond(callback: () => Unit) {
while (true) { callback(); Thread sleep 1000 }
}
def timeFlies() {
println("time flies like an arrow...")
}
def main(args: Array[String]) {
oncePerSecond(timeFlies)
}
}
// vim: set ts=4 sw=4 et: