On page 42 you write: “As we warned, defining this initializer has caused the automatic one to vanish, causing an error in the playground.”
Is this true, it does raise a compile error, but has the automatic initialiser vanished? Is the compile error not due to your having defined an initialiser without parameters, and if so, why then do you suggest you might expect to pass in arguments when initialising an instance?
You go on to say: “Before continuing, let’s make an improvement. As the Vector structure stands, its two initializers have independent code paths. It would be better to have them use one code path by having the parameterless initializer call the initializer which takes both x and y.”
Is it good practice to have two initialisers in this example, and in any event, would the following not suffice?
init() {
(x = 0, y = 0)
}
I am still considering what “code paths” might be. It sounds interesting.
Thanks for taking the time to explain. It isn’t clear why we have two initialisers, at least not until reaching the section on classes, and even then . . . it seems tortured.
Having looked at my code again, I now see what I did. Pesky colons ;]