Created
November 16, 2016 04:14
-
-
Save khanlou/efac5bdf9ff6a0497b489817a7006972 to your computer and use it in GitHub Desktop.
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 SignedInteger { | |
| func times(_ each: () -> ()) { | |
| var count: Self = 0 | |
| while (count < self) { each(); count = count + 1 } | |
| } | |
| } | |
| extension SignedInteger { | |
| func timesWithIndex(_ each: (Self) -> ()) { | |
| var count: Self = 0 | |
| while (count < self) { each(count); count = count + 1 } | |
| } | |
| } | |
| 5.timesWithIndex { i in | |
| print("hello", i) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment