A common problem in programming is when you want the path of options for “what happens next” to split. In structured programming this would generally come in the form of a series of if
/else if
/else
(or whatever the syntax is in your preferred language), or a switch
if your language supports it. Maybe you have a ternary operator for a more compact if
/else
. Maybe you go whole-hog and have some array of function pointers to embed the selection into data. Whatever way you slice it, you have paths of control flow, and you want to choose between them in a structured fashion.
Continue Reading →