Swift Style: An Opinionated Guide to an Opinionated Language by Erica Sadun

Swift Style: An Opinionated Guide to an Opinionated Language by Erica Sadun

Author:Erica Sadun [Sadun, Erica]
Language: eng
Format: azw3
Tags: Pragmatic Bookshelf
Publisher: Pragmatic Bookshelf
Published: 2017-03-30T04:00:00+00:00


switch statement targets of opportunity include any pattern matching that can be listed in a truth or state table. Refactor if statements that traverse multi-element truth tables.

When your switch statement is interested in only one case, consider whether it’s better represented as an if statement.

Combine the states that matter most into a unifying tuple and perform pattern matching against that tuple.

Use where clauses for logic that applies to only one or two cases at most.

Prefer wildcard (_) pattern matching when representing “don’t care” conditions, even when coding logic has narrowed that argument to one remaining value. Including an actual value detracts from the “don’t care” meaning.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.