Thursday, November 1, 2018

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 RSS · Twitter

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.

Leave a Comment