Skip to content

Instantly share code, notes, and snippets.

@madeleine-chercover-hs
Last active December 14, 2017 23:54
Show Gist options
  • Save madeleine-chercover-hs/a352b284f94265ee9242f692ad4b7901 to your computer and use it in GitHub Desktop.
Save madeleine-chercover-hs/a352b284f94265ee9242f692ad4b7901 to your computer and use it in GitHub Desktop.
def eatVegetable(vegetable: Vegetable): String =
vegetable match {
case Pea(colour, isCooked) =>
s"Oh great, a ${if (isCooked) "uncooked" else "cooked" } $colour pea."
case Eggplant(colour, _) =>
s"No matter how I cook this $colour eggplant, it'll still be the blandest vegetable around."
case ChocolateCake(layers, _) =>
s"Yum, a $layers-layer chocolate cake – the best vegetable of all."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment