Another way to change the data in a vector is with the .pop() method, which removes the last element from a vector:
let mut three_arr = vec![1, 4, 6];
// Remove last element:
three_arr.pop();
// three_arr is now vec![1, 4]
// Remove last element again:
three_arr.pop();
// three_arr is now vec![1]
Assignment
Follow the Coding Tutorial and let's play with some arrays.
Hint
Look at the examples above if you get stuck.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check