Created
June 16, 2016 14:13
-
-
Save rowpsmo1859/ad0c34b1f404589d31b5d36d8067bf34 to your computer and use it in GitHub Desktop.
Example of a discriminated union type with member functions attached
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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