title: Twig: get element of an array by key within an if statement
body: <p>I'd like to get the value of an element by key within an if statement.</p>
  
  <p><strong>Example:</strong></p>
  
  <p>works:</p>
  
  <pre><code>{{ example[5] }}
  </code></pre>
  
  <p>doesn't work:</p>
  
  <pre><code>{% if example2 is example[5] %} something ... {% endif %}
  </code></pre>
  
  <p><strong>Exception thrown:</strong></p>
  
  <blockquote>
    <p>Unexpected token "punctuation" of value "[" ("end of statement block" expected)</p>
  </blockquote>
  
  <p>Thank you very much</p>
  
  <p>Kind regards</p>