F# – if/then statement

  • Post author:
  • Post category:F#
  • Post comments:2 Comments
F# - if/then statement

F# if/then statement consists of a Boolean expression followed by one or more statements.

Syntax of F# if/then statement

The if/then construct in F# has the following syntax −

(* simple if *)
if expr then
   expr

Flow diagram

F# - if/then statement

Example

let a : int32 = 10

(* check the boolean condition using if statement *)
if (a < 20) then
   printfn "a is less than 20\n"
   printfn "Value of a is: %d" a

When you compile and execute the program, it yields the following output −

a is less than 20

Value of a is: 10

Next Topic – Click Here

This Post Has 2 Comments

Leave a Reply