Last active
August 29, 2015 14:06
-
-
Save aryaxt/4e9a95d19a3d8e13afbc to your computer and use it in GitHub Desktop.
Int extension - Execute a block based on given number of times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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