The if–let construct has been expanded to allow testing multiple optionals and guarding conditions in a single if (or while) statement using syntax similar to generic constraints:
This allows you to test multiple optionals and include intervening boolean conditions, without introducing undesirable nesting (for instance, to avoid the optional unwrapping “pyramid of doom”).
Further, if–let now also supports a single leading boolean condition along with optional binding let clauses. For example:
The if–let syntax has been extended to support a single leading boolean condition along with optional binding let clauses.
New grammar of condition (since Swift 1.2) should be implemented (same for if-condition)
while-condition -> expression | expression opt optional-binding-list
optional-binding-list -> optional-binding-clause | optional-binding-clause, optional-binding-list
optional-binding-clause -> optional-binding-head optional-binding-continuation-list opt guard-clause opt
optional-binding-head -> let identifier-pattern initializer | var identifier-pattern initializer
optional-binding-continuation-list -> optional-binding-continuation | optional-binding-continuation, optional-binding-continuation-list
optional-binding-continuation -> identifier-pattern initializer | optional-binding-head