March 2018
Beginner to intermediate
458 pages
10h 34m
English
F# uses the let keyword for the declaration of a variable, for example:
let square x = x*x
The compiler automatically detects this as a value type. If we pass a float value, the compiler will be able to understand that without declaring a data type. Variables in F# are immutable, so once a value is assigned to a variable, it can't be changed. They are compiled as static read-only properties.
The following example demonstrates this:
let x:int32 = 50let y:int32 = 30let z:int32 = x + y
Variables x, y, and z are all of type int32 and are immutable, meaning their value cannot be changed.
Let's print their values. The syntax is as follows:
printfn "x: %i" xprintfn "y: %i" yprintfn "z: %i" z
After the preceding code executes, ...
Read now
Unlock full access