For the More Curious: Initializer Parameters
Like functions and methods, initializers can provide explicit external parameter names. External parameter names distinguish between the parameter names available to callers and the local parameter names used in the initializer’s implementation. Because initializers follow different naming conventions than functions (i.e., initializer names are always init), the parameters’ names and types help to determine which initializer should be called. Thus, Swift provides external parameter names for all of the initializer’s arguments by default.
You can provide your own external parameter names as needed. For example, imagine a WeightRecordInLBS struct that should be able to be initialized with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access