title: How to pass an associative array as argument to a function in Bash?
body: <p>How do you pass an associative array as an argument to a function? Is this possible in Bash?</p>
  
  <p>The code below is not working as expected:</p>
  
  <pre><code>function iterateArray
  {
      local ADATA="${@}"            # associative array
  
  for key in "${!ADATA[@]}"
  do
      echo "key - ${key}"
      echo "value: ${ADATA[$key]}"
  
  done
  
  }
  </code></pre>
  
  <p>Passing associative arrays to a function like normal arrays does not work:</p>
  
  <pre><code>iterateArray "$A_DATA"
  </code></pre>
  
  <p>or</p>
  
  <pre><code>iterateArray "$A_DATA[@]"
  </code></pre>