Swift sections
Published in

Swift sections

Ordering completion arguments

If you want to support two completion blocks (closures), one for success and one for failure, I suggest ordering them so that the positive one is the last and, if applicable, also make error handling optional:

This way one can write a client like this:

or when there is no need to handle errors (decided after careful analysis :) ):



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sorin Dolha

Software developer • happy, married, father×2 • Rust, Swift, WPF, Web • founder of DlhSoft • MacBook enthusiast • EDM • writing from Cluj