Count truthy objects in an array <p>I'd like to count truthy objects in an array. Since I can pass a block to count, the most idiomatic way I found was this:</p> <pre><code>[1, nil, 'foo', false, true].count{ |i| i } =&gt; 3 </code></pre> <p>But I was wondering if there was a better way, especially using the syntax <code>count(&amp;:something)</code>, because passing a full block here looks like overkill to me.</p> <p>AFAIK, there is no <code>truthy?</code> method in Ruby, so I couldn't find how to achieve this.</p>