What's the best way to pass an associative array as an argument to a function to avoid the repetition of having to iterate over numerous associate arrays? That way I can give the function any array of my choice to print. Here's what I have:
# Snippet
declare -A weapons=(
['Straight Sword']=75
['Tainted Dagger']=54
['Imperial Sword']=90
['Edged Shuriken']=25
)
print_weapons() {
for i in "${!weapons[@]}"; do
printf "%s\t%d\n" "$i" "${weapons[$i]}"
done
}
print_weapons