Groovy addAll makes a list of lists
<p>this might not be the best question but I am curious about what might be going on.</p>

<p>I have this piece of code in groovy</p>

<pre><code>def markets = []
for (int i = 0; i &lt; marketIds.size(); i += 200) {
    int from = i
    int to = (i + 200) &gt; marketIds.size() ? marketIds.size() : (i + 200)
    markets.addAll(service.getMarketCatalog(args...))
}

markets
</code></pre>

<p><code>service.getMarketCatalog()</code> returns a list of objects/maps (it's a call to 3rd part API that returns a list of some objects defined in their API. We get them as maps).</p>

<p>For some reason the result of this method is markets being a list of lists. 
So if the for loop runs 3 times and the API responds each time with a list, the list is added to the markets as an object.</p>

<p>Anyone have any ideas why? Maybe I have to define that the result is a list (i.e. <code>service.getMarketCatalog(args...) as List</code>) otherwise it is treated as an object and just gets added as an object to the list?</p>