O'Reilly logo

Swift Programming: The Big Nerd Ranch Guide by John Gallagher, Matthew Mathias

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required