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."
type Person = { Name : string; Gender : string }- type Gender = Male | Female
- type Person = { Name : string; Gender : Gender }
let alice = { Name = "Alice"; Gender = "Female" }let bob = { Name = "Bob"; Gender = "Male" }- let alice = { Name = "Alice"; Gender = Female }
- let bob = { Name = "Bob"; Gender = Male }
- let femaleOrMale p =
match p with| { Gender = "Female" } -> p.Name + " is female."| { Gender = "Male" } -> p.Name + " is male."| _ -> "???"- match p.Gender with
- | Female -> p.Name + " is female."
- | Male -> p.Name + " is male."