Thursday, November 1, 2018 [Tweets] [Favorites]

Swift’s “if case let” Syntax

Zoe Smith (via Jim Correia):

case let immediately precedes the candidate pattern in both versions. However, when using if case let the value comes after the = operator

[…]

case let is a shortcut so all subsequent associated values can be bound just by providing variable names.

[…]

Add conditions to if and guard using commas

[…]

Iterate using for, where and logical operators

See also: Swift Closures and Objective-C Blocks.

2 Comments

I kinda of wish this syntax didn't exist

The existence of these “fucking___syntax.com” web sites is a testament to obscure and over-wrought syntactical design, and it's disheartening to witness their need in a shiny new language like Swift.

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment