January 2020
Intermediate to advanced
470 pages
11h 13m
English
A common problem in programming is dealing with missing values. There are many possible causes for this situation: a web service Ajax call may have returned an empty result, a dataset could be empty, an optional attribute might be missing from an object, and so on. Dealing with this kind of situation, in a normal imperative fashion, requires adding if statements or ternary operators everywhere to catch the possible missing value in order to avoid a certain runtime error. We can do a bit better by implementing a Maybe functor to represent a value that may (or may not) be present! We will use two classes, Just (as in just some value) and Nothing, both of which are functors themselves. The Nothing functor ...
Read now
Unlock full access