Lesson 22. Fixing the billion-dollar mistake

Hopefully, in the preceding lesson, you gained at least an initial appreciation of discriminated unions and how they allow you to quickly and easily model complex relationships. In this lesson, you’ll take a look at one specific discriminated union that’s built into F# and designed to solve a single problem: nothing! Or, more seriously, handling null values. You’ll learn about

  • Dealing with absence-of-value situations in .NET today
  • Working with optional data in F#
  • Using helper F# functions to deal with common optional scenarios

22.1. Working with missing values

Imagine you’re reading a JSON document from a car insurer that contains information on a driver, including a safety rating that’s used to ...

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