Exerpad
🔥 0
0 XP
Exercise 1 · Chapter: Error HandlingRequired+50 XP

Option Match

Create a vector of animals ["cat", "dog", "fish"]. Use match with .get() to look up index 1 and index 5. Print what you find!

Expected output:

Index 1: dog
Index 5: not found

Hints:

  • Use animals.get(1) which returns Option<&&str>
  • Match on Some(animal) and None
rust
fn main() {
}
Output
Run your code to see the output here.