Instantly share code, notes, and snippets.

Embed
What would you like to do?
In model/business logic returning collections, returning nil adds complexity to consumer logic.
func modelLayerFunction() -> [Any]? { /* ... */ }
func controllerFunction() -> [Any]? {
guard let models = modelLayerFunction() else {
// log error and/or show alert?
return nil
}
// ...
return models
}
if let result = controllerFunction() {
// work with result
} else {
// log error and/or show alert?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment