All posts tagged “closure

comment 0

#49 The Builder Pattern

In issue #41 in which we have built an app that uses a photo camera to capture one’s loayalty cards we used a pattern that we named Builder to configure properties of objects. How does the code look like when we use Builder pattern? We simply initialize an object we want to configure and call the with(:) function on the…

comments 2

#32 Errorify String

Swift.Error Swift introduces pattern of throwing errors, to propagate error conditions in a program. Errors are represented by types that conform to empty Error protocol, usually enum types. If you want to propagate an error condition in your app, you can use your AppError enum for that: The throws keyword says that a function can propagate an error, so it…

comment 1

#29 An alternative to if let and guard let

It’s brilliant when you can work with people smarter (or even a lot smarter) than you! You can learn so much from them. And then write about the things you’ve learned 🙃. if and guard let Have you ever been tired of repeating if let or guard let statements, to perform certain operations, that should be performed only if a…