How to use with block configure in Swift
Issue #786
Sometimes we need to update some properties between objects, for example
1 | book.name = updatedBook.name |
Repeating the caller book
is tedious and error-prone. In Kotlin, there is with block which is handy to access the receiver properties and methods without referring to it.
1 | with(book) { |
In Swift, there are no such thing, we can write some extension like
1 | extension Book { |
Or simply, we can just use forEach
with just that book
1 | [book].forEach { |