- F# Basic Tutorial
- F# - Home
- F# - Overview
- F# - Environment Setup
- F# - Program Structure
- F# - Basic Syntax
- F# - Data Types
- F# - Variables
- F# - Operators
- F# - Decision Making
- F# - Loops
- F# - Functions
- F# - Strings
- F# - Options
- F# - Tuples
- F# - Records
- F# - Lists
- F# - Sequences
- F# - Sets
- F# - Maps
- F# - Discriminated Unions
- F# - Mutable Data
- F# - Arrays
- F# - Mutable Lists
- F# - Mutable Dictionary
- F# - Basic I/O
- F# - Generics
- F# - Delegates
- F# - Enumerations
- F# - Pattern Matching
- F# - Exception Handling
- F# - Classes
- F# - Structures
- F# - Operator Overloading
- F# - Inheritance
- F# - Interfaces
- F# - Events
- F# - Modules
- F# - Namespaces
- F# Useful Resources
- F# - Quick Guide
- F# - Useful Resources
- F# - Discussion
F# - if/then statement
An if/then statement consists of a Boolean expression followed by one or more statements.
Syntax
The if/then construct in F# has the following syntax −
(* simple if *) if expr then expr
Flow diagram
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
fsharp_decision_making.htm
Advertisements