Created
June 24, 2018 14:34
-
-
Save kennetpostigo/4e5e20a67cdd16b0db101eb4688a7007 to your computer and use it in GitHub Desktop.
Reason BST Blog Post pattern matching
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 pets = | |
| Dog(string) | |
| Cat(string) | |
| Hamster(string); | |
let myPet = Dog("Buddy"); | |
switch (myPet) { | |
| Dog(name) => "I have a Dog " ++ name ++ "!" | |
| Cat(name) => "I have a Cat " ++ name ++ "!" | |
| Hamster(name) => "I have a Hamster " ++ name ++ "!"; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment