<p>I have a variable of type <code>Dynamic</code> and I know for sure one of its fields, lets call it <code>a</code>, actually is an array. But when I'm writing </p>

<pre><code>var d : Dynamic = getDynamic();
for (t in d.a) {
}
</code></pre>

<p>I get a compilation error on line two:</p>

<blockquote>
  <p>You can't iterate on a Dynamic value, please specify Iterator or Iterable</p>
</blockquote>

<p>How can I make this compilable?</p>

[{'answer_id': 51802, 'author': 'Danny Wilson', 'author_id': 5364, 'author_profile': 'https://Stackoverflow.com/users/5364', 'pm_score': 4, 'selected': True, 'text': "<p>Haxe can't iterate over <code>Dynamic</code> variables (as the compiler says).</p>\n\n<p>You can make it work in several ways, where this one is probably easiest (depending on your situation):</p>\n\n<pre><code>var d : {a:Array&lt;Dynamic&gt;} = getDynamic();\nfor (t in d.a) { ... }\n</code></pre>\n\n<p>You could also change <code>Dynamic</code> to the type of the contents of the array.</p>\n"}, {'answer_id': 67059, 'author': 'Michael Pliskin', 'author_id': 9777, 'author_profile': 'https://Stackoverflow.com/users/9777', 'pm_score': 2, 'selected': False, 'text': '<p>Another way to do the same is to use an extra temp variable and explicit typing:</p>\n\n<pre><code>var d = getDynamic();\nvar a: Array&lt;Dynamic&gt; = d.a;\nfor (t in a) { ... }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/51781', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']