Last active
June 24, 2020 13:33
-
-
Save Sethathi/755a3dc5367cebfe48a32b9ddfb032e1 to your computer and use it in GitHub Desktop.
This file contains 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
// What's the output of this code? | |
extension Int { | |
func times(callback: (_ n: Int) -> ()) { | |
for n in 0...self { | |
callback(n) | |
} | |
} | |
} | |
2.times { (n) in | |
print("line #\(n)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment