Scala: How to use higher-order functions with Option (instead of match expressions)
By Alvin Alexander. Last updated: July 15 2019
Table of Contents
I originally wrote a long introduction to this article about Scala Options, but I decided to keep that introduction for a future second article in this series. For this article I’ll just say:
- idiomatic Scala code involves never using null values
- because you never use nulls, it’s important for you to become an expert at using
Option
,Some
, andNone
- initially you may want to use match expressions to handle
Option
values - as you become more proficient with Scala and Options, you’ll find that match expressions tend to be verbose
- becoming proficient with higher-order functions (HOFs) like
map
,filter
,fold
, and many others are the cure for that verbosity