Jpqju64fnoaobncgruer
SkillsCast

Switch Statements and Pattern Making

18th August 2014 in London at Skills Matter

There are 4 other SkillsCasts available from Swift London | Talks

"Powerful new ways to control the flow of your code."

In Swift, switch statements are introduced as "A switch statement considers a value and compares it against several possible matching patterns. It then executes an appropriate block of code, based on the first pattern that matches successfully." Anyone used to using a C based language, such as Objective-C or C++, will know that the only form of 'matching' is with integer values.

This essentially reduces a 'switch' statement to shorthand for a bloated if....else statement. “Matching patterns" does not just mean other types such as doubles, strings and non integer enumerations. It means values within tuples, matching against ranges and even matching against additional conditions.

All of this functionality gives swift developers powerful new ways to control the flow of their code. One obvious use is to neaten complex table and collection views but that is not the only use. This presentation will attempt to introduce this powerful language feature and detail some interesting uses which have arisen in the early days of the language.

Twitter @LiamFlynn

YOU MAY ALSO LIKE:

Switch Statements and Pattern Making

SkillsCast

"Powerful new ways to control the flow of your code."

In Swift, switch statements are introduced as "A switch statement considers a value and compares it against several possible matching patterns. It then executes an appropriate block of code, based on the first pattern that matches successfully." Anyone used to using a C based language, such as Objective-C or C++, will know that the only form of 'matching' is with integer values.

This essentially reduces a 'switch' statement to shorthand for a bloated if....else statement. “Matching patterns" does not just mean other types such as doubles, strings and non integer enumerations. It means values within tuples, matching against ranges and even matching against additional conditions.

All of this functionality gives swift developers powerful new ways to control the flow of their code. One obvious use is to neaten complex table and collection views but that is not the only use. This presentation will attempt to introduce this powerful language feature and detail some interesting uses which have arisen in the early days of the language.

Twitter @LiamFlynn

YOU MAY ALSO LIKE:

About the Speaker

Switch Statements and Pattern Making