<p dir="auto">It would be nice to be able to write:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[f() for 1:n]"><pre class="notranslate">[<span class="pl-c1">f</span>() <span class="pl-k">for</span> <span class="pl-c1">1</span><span class="pl-k">:</span>n]</pre></div>
<p dir="auto">instead of</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[f() for _ in 1:n]"><pre class="notranslate">[<span class="pl-c1">f</span>() <span class="pl-k">for</span> _ <span class="pl-k">in</span> <span class="pl-c1">1</span><span class="pl-k">:</span>n]</pre></div>
<hr>
<p dir="auto">Here is some context: I wanted to build a <code class="notranslate">Vector{Vector{Float64}}</code> containing empty <code class="notranslate">Vector{Float64}</code>s.<br>
<code class="notranslate">Array(Vector{Vector{Float64}}, n)</code> doesn't work because the inner vectors are undefined. <code class="notranslate">repeat(Float64[], outer=[n])</code> doesn't work because it is just concatenating empty arrays. <code class="notranslate">collect(repeated(Float64[], n))</code> works and so does <code class="notranslate">[Float64[] for _ in 1:n]</code>, but it could be prettier. That's why I am proposing this teaspoon of syntactic sugar.</p>
<p dir="auto">Not a game changer but it could be a nice little addition.</p>
<p dir="auto"><sub>I apologize if this was brought up before. I couldn't find it.</sub></p>
<p dir="auto">Especially with comprehensions I do this by accident fairly often:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="[@elapsed f() for 1:10]"><pre class="notranslate">[<span class="pl-c1">@elapsed</span> <span class="pl-c1">f</span>() <span class="pl-k">for</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span>]</pre></div>
<p dir="auto">We could support the same for loops:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="for 1:10 f() end"><pre class="notranslate"><span class="pl-k">for</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">10</span> <span class="pl-c1">f</span>() <span class="pl-k">end</span></pre></div>
<p dir="auto">Not super crucial, but seems like something we might as well allow.</p>