Last active
August 29, 2015 14:02
-
-
Save Nub/79159c335de85b8521ee 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
// Playground - noun: a place where people can play | |
import Cocoa | |
func foo(done: ((String) -> Void), bar: String = "default"){ | |
done(bar) | |
} | |
// It works!, but what if I want to set bar? | |
foo(){(bar: String) in | |
println(bar) | |
} | |
// No workie | |
//foo(bar: "test"){(bar: String) in | |
// println(bar) | |
//} | |
// Ugh I guess rewrite, but works | |
foo({(bar: String) in | |
println(bar) | |
}, bar: "test") | |
func foo2(bar: String = "z", done: ((String) -> Void)){ | |
done(bar) | |
} | |
// No workie | |
//foo2(){(bar: String) in | |
// println(bar) | |
//} | |
// Works now, but still not usage of defaults | |
foo2(bar: "test2"){(bar: String) in | |
println(bar) | |
} | |
func foo3(bar: String = "z", _ done: ((String) -> Void) = {x in println("default")} | |
){ | |
done(bar) | |
} | |
// No workie | |
//foo3(){(bar: String) in | |
// println(bar) | |
//} | |
// Works, but no default value | |
foo3(bar: "test3"){(bar: String) in | |
println(bar) | |
} | |
// Works, but useless | |
foo3() | |
foo3(bar: "test4") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment