Railway-oriented programming

Railway-oriented programming comes into the picture when we need to bring functional concepts in error handling within our code base.

In general programming, a developer spends most of their time thinking about "the happy path," that is, when everything goes according to plan and is just done right, and they don't spend enough time thinking what will happen if things go wrong; that's what railway-oriented programming is all about. In an imperative world, when things go wrong, or in other words the code throws some kind of error, there is a certain way of handling those errors and the process is called exception handling. In this section, we will cover how to handle errors and exceptions in a functional way.

Get Reactive Programming with Swift 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.