Exerpad
🔥 0
0 XP
Exercise 4 · Chapter: Enums & Pattern MatchingRequired+50 XP

Animal Sound

Define an enum called Animal with four variants: Cat, Dog, Cow, and Duck.

Create a variable set to Animal::Duck and use match to print each animal's sound:

  • Cat => Meow
  • Dog => Woof
  • Cow => Moo
  • Duck => Quack

Expected output:

Quack

rust
fn main() {
}
Output
Run your code to see the output here.