Last active
March 29, 2016 22:04
-
-
Save pilky/d0893c6a146220a43db5090e520b8f18 to your computer and use it in GitHub Desktop.
Swift argument swapping weirdness
This file contains hidden or 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
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