How can I pass a variable number of args to a yield. I don’t want to pass an array (as the following code does), I’d actually like to pass them as a programmatic number of args to the block.
def each_with_attributes(attributes, &block) results[:matches].each_with_index do |match, index| yield self[index], attributes.collect { |attribute| (match[:attributes][attribute] || match[:attributes]['@#{attribute}']) } end end
Use the splat-operator
*to turn the array into arguments.or