Ruby Symbol and String Array Shorthand

<p>Ruby has some handy Array shorthands, but I always forget which is which, so I thought I should write them down.</p> <h3 id="symbol-array-shorthand">Symbol Array Shorthand:</h3> <div class="highlight"><pre class="highlight ruby"><code><span class="sx">%i{foo bar}</span> <span class="c1"># =&gt; [:foo, :bar]</span> </code></pre></div> <h3 id="string-array-shorthand">String Array Shorthand:</h3> <div class="highlight"><pre class="highlight ruby"><code><span class="sx">%w{foo bar}</span> <span class="c1"># =&gt; ["foo", "bar"]</span> </code></pre></div> <p>Both also work with square brackets <code>%w[a b c]</code> or parenthesis <code>%i(a b c)</code></p>