Wrapping Up

We’ve reached the end of the book. We’ve discussed the advantages and disadvantages of four strategies to handle uncertain values in functions. With this knowledge, you can promote changes in your codebase to achieve a low maintenance cost. Let’s review what you’ve learned in this chapter:

  • Impure functions can result in unexpected values because they depend on values that are not in the function’s scope.

  • case, if, and other control-flow statements are good for handling simple cases. Combining multiple conditional statements produces code that’s hard to understand. You should avoid it.

  • The try statement works with libraries where you don’t control the code. These libraries can raise errors or throw values. Functions that return values ...

Get Learn Functional Programming with Elixir 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.