Don’t return — NEVER in Swift

Not nil, not null

Image for post
Image for post
Photo by David Besh on Unsplash

Prerequisites:

Terminology

The source of this article

extension Subscribers {class Assign<Root, Input>: Subscriber, Cancellable {typealias Failure = Neverinit(object: Root, keyPath: ReferenceWritableKeyPath<Root, Input>)}}

The documentation

func crashAndBurn() -> Never {    fatalError("Something very, very bad happened")}
func crashAndBurn() {    fatalError("Something very, very bad happened")}

Why Never?

Conclusion

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