Skip to content

Instantly share code, notes, and snippets.

@rowpsmo1859
Created June 16, 2016 14:13
Show Gist options
  • Select an option

  • Save rowpsmo1859/ad0c34b1f404589d31b5d36d8067bf34 to your computer and use it in GitHub Desktop.

Select an option

Save rowpsmo1859/ad0c34b1f404589d31b5d36d8067bf34 to your computer and use it in GitHub Desktop.
Example of a discriminated union type with member functions attached
type test =
| One
| Two
member this.Add =
let number =
match this with
| One -> 1
| Two -> 2
(fun secondNumber -> number + secondNumber)
One.Add 2 //Output 3
Two.Add 3 //Output 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment