Skip to content

Instantly share code, notes, and snippets.

@aryaxt
Last active August 29, 2015 14:06
Show Gist options
  • Save aryaxt/4e9a95d19a3d8e13afbc to your computer and use it in GitHub Desktop.
Save aryaxt/4e9a95d19a3d8e13afbc to your computer and use it in GitHub Desktop.
Int extension - Execute a block based on given number of times
extension Int {
public func execute (closure: () -> Void) {
for index in 1...self {
closure()
}
}
}
// Usage
10.execute { println("print times") }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment