December 2018
Intermediate to advanced
414 pages
10h 19m
English
In Swift, we have the nice benefit of having structs automatically generate their constructor. This saves a lot of boilerplate code when creating new instances of structs.
Let's consider this Article struct. You could use this to represent an article for a blog, for example:
struct Article { let id: String let title: String let contents: String let author: String let date: Date var views: Int}
Creating new Article instances is quite labor-intensive, as you need to gather all the parameters and use them at once in the same code place. However, using the builder pattern, you could pass the builder around your code and, when the whole content is ready, create the article structure.
In editors such as IntelliJ for Java, you could ...
Read now
Unlock full access