16 Partial functions

After reading this lesson, you will be able to

  • Implement partial functions to abstract commonalities between functions
  • Create new functions by composing partial functions
  • Use a try-catch expression to handle exceptions

Now that you’ve learned about pattern matching, you’ll discover partial functions and how they relate to pattern matching in this lesson. Partial functions are functions that are defined only for some input. You’ll see how they can be useful to abstract commonalities between functions and how you can compose them to create more complex functionalities. Finally, you’ll see how you can use partial functions to catch and handle exceptions. In the capstone, you’ll use partial functions to define the routes ...

Get Get Programming with Scala 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.