Skip to content

Instantly share code, notes, and snippets.

@pilky
Last active March 29, 2016 22:04
Show Gist options
  • Save pilky/d0893c6a146220a43db5090e520b8f18 to your computer and use it in GitHub Desktop.
Save pilky/d0893c6a146220a43db5090e520b8f18 to your computer and use it in GitHub Desktop.
Swift argument swapping weirdness
func f(a a: Int = 0, b: Int = 0, c: Int, d: Int = 0, e: Int = 0) -> (Int, Int, Int, Int, Int){
return (a, b, c, d, e)
}
f(c:3)
f(a:1, c:3)
f(b:2, c:3)
f(a:1, b:2, c:3)
f(b:2, a:1, c:3)
f(b:2, c:3, a:1) //Bad
f(c:3, d:4, e:5)
f(d:4, c:3, a:1) //Doubly Bad
f(b:2, a:1, c:3, e:5, d:4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment