I figured out the Bronze challenge at the end of 5. Except for one thing.
let point = (x: 1, y: 4)
switch point { case let q1 where (point.x > 0) && (point.y > 0):
How does q1 become the value of “point”
I get what is going on, i just don’t get the mechanic of q1 is = to point now.
Otherwise great book… enjoying it, and that is rare for reading a programming book.
This is value binding as seen on p.40. “Value binding allows you to bind the matching value in a certain case to a local constant to variable. The constant of variable is available to use only within the matching case’s body”
Also, the following if-statement does the same thing.
if point.x > 0 && point.y > 0 { let q1 = point ... } else if ... { } ... else { ... }
You can always recast a switch statement as an if statement.