F# For Dummys - Day 4

118 阅读1分钟

Today we learn how to define and store a value
there are different types of value
we introduce 4 of them

TypeDescription
boolpossible values are true or false
intValues from -2,147,483,648 to 2,147,483,647.
stringUnicode text
float, doubleA 64-bit floating point type.
  • bool is data type indicate yes or no

1715826078833.jpg

let is_this_apple: bool = true
let is_this_orange: bool = false

: bool is type hint, tell compiler type of the variable we define is bool, normally we omit the type hint, as compiler is smart enough to infer the type itself, so we can also define as below

let is_this_apple = true
let is_this_orange = false
  • int is integer

image.png

let number_of_people_in_family: int = 5
  • string is a section of text

image.png

let dream_of_girl = "have food with grandma in warm place"
  • float and double is decimal, a number with fraction part

1715827659784.jpg

let price_of_milk = 1.19