Natalia Panferova writes about Swift enum pattern matching with extra conditions and goes over:
whileloops with extra conditions (
- (Missing, for completion:
catch ... wherein
I believe there’s tremendous value in summaries like these to learn the Swift programming language and its syntax: these short summaries show a slice of different aspects of the language in close proximity.
The Swift language book tells you all about the structural programming features one after another in the Control Flow chapter:
It also has a section on
where, but that’s limited to the
switch conditional statement.
The section on
for loops doesn’t mention
where clauses at all! You need to go to the Language Reference part of the book, where the formal grammar is explained, to read that a
where-clause? is allowed.
inexpression where-clause? code-block
So a post like Natalia’s reminds us about the similarity of different aspects of the Swift programming language.
It’s zooming in on where-clauses, and so the reader gets to know a different “view” into the syntax as a whole that is different from the book’s presentation.
This should be very valuable to get from beginner-level understanding of “I can do things in Swift” to a deeper understanding of recognizing similarities across different aspects of the programming language.
These should, in my opinion, be included in the language’s handbook to help with “deep learning”. Until then, I’m glad we have posts like Natalia’s!