Skip to content

Instantly share code, notes, and snippets.

@marcinbunsch
Created October 14, 2009 20:26
Show Gist options
  • Save marcinbunsch/210367 to your computer and use it in GitHub Desktop.
Save marcinbunsch/210367 to your computer and use it in GitHub Desktop.
Array#invoke
class Array
# invoke a method on each element of the array and return an array of return values
def invoke(method_name, *args, &block)
collect { |item| item.send(method_name, *args, &block) }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment