Summary
In this module, you learned how to apply conditional logic to a program. By adding conditional logic, you create multiple execution paths through the program. Most programs have multiple paths because that makes a program flexible.
You explored the if...elif...else
construct and learned how to apply it. Conditional logic in F# is different from how most languages do conditional logic. In F#, conditional logic runs expressions that produce a value.
Finally, you were presented with three types of loops: for...in
, for...to
, and while...do
. The functionality of the three loop constructs varies, so which loop you might use depends on your objective. for...in
iterates over an enumerable collection. for...to
iterates until a looping variable is reached, whether it's incrementing or decrementing that value. while...do
focuses on a Boolean condition that, when evaluated to false
, breaks the loop.