Skip to content

Instantly share code, notes, and snippets.

@andybest
Created July 6, 2014 18:34
Show Gist options
  • Select an option

  • Save andybest/d3019ff1742012dbcf42 to your computer and use it in GitHub Desktop.

Select an option

Save andybest/d3019ff1742012dbcf42 to your computer and use it in GitHub Desktop.
Adding Ruby-like times method to Swift integers
extension Int {
func times(it: () -> ()) {
for i in 0..self {
it()
}
}
}
// Use like so:
10.times {
println("Hello, World!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment