Skip to content

Instantly share code, notes, and snippets.

@dvanwinkle
Created June 15, 2015 21:39
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 dvanwinkle/4461add9386b23c53788 to your computer and use it in GitHub Desktop.
Save dvanwinkle/4461add9386b23c53788 to your computer and use it in GitHub Desktop.
Create Custom While Loop in Swift
func while1(@autoclosure c: () -> Bool, body: () -> ()) {
println("here")
if c() {
body()
while1(c, body)
}
}
var counter = 0
while1(counter < 10) {
++counter
print("Counter = \(counter)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment