/src/main/scala/scalagym/Demo.scala
http://github.com/mariofusco/scalagym · Scala · 23 lines · 13 code · 7 blank · 3 comment · 1 complexity · 5bccba9f37bf1fd56265e4bf7db61aad MD5 · raw file
- package scalagym
- import annotation.tailrec
- /**
- * @author Mario Fusco
- */
- object Demo extends Application {
- implicit def intToLooper(n: Int) = new { def times(f: => Unit): Unit = Demo.times(n)(f) }
- twice {
- 3 times {
- println("Hello world!")
- }
- }
- def twice(f: => Unit): Unit = { f; f; }
- @tailrec
- def times(n: Int)(f: => Unit): Unit = if (n > 0) { f; times(n-1)(f) }
- }