Skip to content

Instantly share code, notes, and snippets.

@Sethathi
Last active June 24, 2020 13:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sethathi/755a3dc5367cebfe48a32b9ddfb032e1 to your computer and use it in GitHub Desktop.
Save Sethathi/755a3dc5367cebfe48a32b9ddfb032e1 to your computer and use it in GitHub Desktop.
// 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