Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Remove Item

Create a vector with "apple", "banana", and "cherry". Remove "banana" from the vector, then print the remaining items, one per line.

Expected output:

text
apple
cherry

Hints:

  • Use .retain() to keep only the items you want
  • .retain(|&x| x != "banana") keeps everything that is NOT "banana"
  • Don't forget mut since you're changing the vector!
rust
fn main() {
}