Skip to content

Instantly share code, notes, and snippets.

@lildata
Created May 19, 2015 20:12
Show Gist options
  • Save lildata/8b2a437251812a8c86e9 to your computer and use it in GitHub Desktop.
Save lildata/8b2a437251812a8c86e9 to your computer and use it in GitHub Desktop.
how to create a X times syntax with implicits, also cool for DSLs
implicit def intWithTimes(n: Int) = new {
def times(f: => Unit) = 1 to n foreach {_ => f}
}
5 times {
println("Hello World")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment