Ad
Code
Diff
  • type Gender = Male | Female    
    type Person = { Name : string; Gender : Gender }
    
    let alice = { Name = "Alice"; Gender = Female }
    let bob = { Name = "Bob"; Gender = Male }
    
    let femaleOrMale = function 
      | { Name = name; Gender = Female } -> name + " is female."
      | { Name = name; Gender = Male } -> name + " is male."
    • type Gender = Male | Female
    • type Person = { Name : string; Gender : Gender }
    • let alice = { Name = "Alice"; Gender = Female }
    • let bob = { Name = "Bob"; Gender = Male }
    • let femaleOrMale p =
    • match p.Gender with
    • | Female -> p.Name + " is female."
    • | Male -> p.Name + " is male."
    • let femaleOrMale = function
    • | { Name = name; Gender = Female } -> name + " is female."
    • | { Name = name; Gender = Male } -> name + " is male."