Skip to content

Instantly share code, notes, and snippets.

@marcinbunsch
Created October 14, 2009 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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