Skip to content

Instantly share code, notes, and snippets.

@souhe
Last active November 22, 2018 23:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save souhe/311ce474159e08f631c6bba13f5b717e to your computer and use it in GitHub Desktop.
Save souhe/311ce474159e08f631c6bba13f5b717e to your computer and use it in GitHub Desktop.
switch (userWithReview) {
| { name: "Maja", phone: "123123", review: Neutral, age: 24 } =>
"Here we match every value with name Maja, phone 123123 Neutral review and age 24"
| { name: "Maja", phone } =>
"Here we match every value with name Maja and we can use phone like a normal variable - " ++ phone
| { name, phone, review: Awesome} =>
"Here we match every user with review Awesome and we can use phone and name"
| { name, phone, review: Bad(explanation)} =>
"Here we match every user with review Baw and we can use phone, name, and the explanation"
| _ =>
"Here we match everything else"
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment