I'm an experienced C, C++, and Java programmer looking to port an app to the iOS environment. I'm learning Swift by using three sources: the Swift iOS 24-hour Trainer, the Apple documentation at https://developer.apple.com/library/...age/index.html
, and testing using a playground on my Mac Mini.
I'm finding Swift's handling of parameters in function calls bizarre. I think neither the book nor the Apple pages explain it well.
From what I've been able to suss out, function parameters may be either positional as in myPositionalFunc(1,2,3) or named as in myNamedFunc(x:1,y:2,z:3). The name MUST NOT appear in the call if the parameter is positional, and the name MUST appear if the parameter is named, i.e., there's no choice about whether or not to include the name in the call.
The first parameter is different from the second and following parameters. The first parameter is positional by default, but it is named if the function definition is declared with an external name.
The second and following parameters are named by default, but they are positional if the function definition is declared with an external name of "_".
init() seems to be a special case. All parameters are named by default.
Is there anywhere in the book or the Apple documentation I can go to see if my analysis of this behavior is correct?