DEV Community

AllenZhu
AllenZhu

Posted on • Edited on

F# For Dummys - Day 4 Value

Today we learn how to define and store a value

there are different types of value, we introduce 4 of them

  • bool is data type indicate yes or no Image description
let is_this_apple: bool = true
let is_this_orange: bool = false
Enter fullscreen mode Exit fullscreen mode

: 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
Enter fullscreen mode Exit fullscreen mode
  • int is integer Image description
let number_of_people_in_family: int = 5
Enter fullscreen mode Exit fullscreen mode
  • string is a section of text Image description
let dream_of_girl = "have food with grandma in warm place"
Enter fullscreen mode Exit fullscreen mode
  • float and double is decimal, a number with fraction part Image description
let price_of_milk = 1.19
Enter fullscreen mode Exit fullscreen mode

Top comments (0)