 <p>Check out <strong><a href="http://www.ruby-doc.org/core-2.2.0/Array.html#method-i-map" rel="nofollow">Array#map</a></strong>. </p> <pre><code>ids = [ 123, 456 ] connections = ids.map do |id| @graph.get_connections("#{ id }","?fields=posts") end </code></pre>