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

16 lines
303 B
Scala
Raw Normal View History

2012-03-04 04:15:05 +00:00
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: