Tracks
/
F#
F#
/
Syllabus
/
Booleans
Bo

Booleans in F#

15 exercises

About Booleans

Booleans in F# are represented by the bool type, which values can be either true or false.

F# supports three boolean operators: not (NOT), && (AND), and || (OR). The && and || operators use short-circuit evaluation, which means that the right-hand side of the operator is only evaluated when needed.

true || false // => true
true && false // => false

The three boolean operators each have a different operator precedence. As a consequence, they are evaluated in this order: not first, && second, and finally ||. If you want to 'escape' these rules, you can enclose a boolean expression in parentheses (()), as the parentheses have an even higher operator precedence.

not true && false   // => false
not (true && false) // => true
Edit via GitHub The link opens in a new window or tab

Learn Booleans