Arrays in bash were not designed for use as mutable data structures. They are primarily used for storing lists of items in a single variable without needing to waste a character as a delimiter (e.g., to store a list of strings which can contain whitespace). We can however remove an element from an array by looping through the array and rebuilding it as a temporary array, set the array to the temporary array and then finally unset the temporary array.
#!/bin/bash
example() {
local i args tmp_args=()
args=("$@")
echo "${#args[@]} args before the filter: ${args[*]}"
if [[ " ${args[*]} " =~ " --load-deps-locally " ]]; then