title: twig - building array in for loop
body: <p>is it possible to iteratively fill a twig array with values? </p>
  
  <pre><code>{% for question in questions %}
  {% set multipleChoiceArray = [] %}
      {% for multipleChoice in question.multipleChoiceAnswers %}
          {% set multipleChoiceArray = multipleChoiceArray|merge( multipleChoice.answerText )  %}
      {% endfor %}
  {% endfor %}
  </code></pre>
  
  <p>the problem is here <code>multipleChoiceArray|merge(multipleChoice.answerText)</code></p>
  
  <p>when i try to pass an array for example with key = loop.index like </p>
  
  <pre><code>{% set multipleChoiceArray = multipleChoiceArray|merge({"loop['index']":"multipleChoice['answerText']"})  %}
  </code></pre>
  
  <p>it works but the array contains the strings "["loop['index']":"multipleChoice['answerText']"]"</p>
  
  <p>when i try to pass variables like :</p>
  
  <pre><code>{% set multipleChoiceArray = multipleChoiceArray|merge({loop.index:multipleChoice.answerText})  %}
  </code></pre>
  
  <p>exception is : A hash key must be followed by a colon (:). Unexpected token "punctuation" of value "." ("punctuation" expected with value ":")</p>
  
  <p>so i am not able to "push" a value "multipleChoice.answerText" into "multipleChoiceArray"</p>
  
  <p>any hints how that is possible ? 
  i just want to gather all possible answers and later check if answer is in that array and count sth up and display</p>