Re-implement if let in Swift
Write your own!
I’ve previously re-implemented Optionals in Swift. What if we were to do the same with if let?
Are you along for this ride?
Difficulty: Beginner | Easy | Normal | Challenging
Prerequisites:
- Be able to produce a “Hello, World!” iOS application (guide HERE)
- Knowledge of if let is required
and the following would be nice to have
Terminology
Closure: A self-contained block of functionality that can be passed around
Generics: Reusable functions and types that can work with any type (or subset of a certain type
Optional: Swift introduced optionals that handle the absence of a value, simply by declaring if there is a value or not. An optional is a type on it’s own!
Optional Binding: Using an if let pattern to unwrap an optional safely
String: A collection of Characters, commonly thought of as a word or sentence