- Mastering macOS Programming
- Stuart Grimshaw
- 75字
- 2021-07-02 22:54:34
Chaining
We can also chain applications:
let results2 = collections.flatMap({$0}).filter({ $0 <10 })
Again, see if you can work out what type and value results2 will have, before running the code.
Knowing when to stop:
Like so many things in code writing, the extent to which you can reasonably chain and nest such statements should depend on code readability. It's not very smart to write code that looks very clever, if nobody can understand it.
Like so many things in code writing, the extent to which you can reasonably chain and nest such statements should depend on code readability. It's not very smart to write code that looks very clever, if nobody can understand it.