Skip to content

Instantly share code, notes, and snippets.

@trptcolin
Forked from patmaddox/collate.rb
Created January 6, 2010 06:38
Show Gist options
  • Save trptcolin/270082 to your computer and use it in GitHub Desktop.
Save trptcolin/270082 to your computer and use it in GitHub Desktop.
module Kernel
def collate(*methods)
methods.map {|m| send(m)}
end
end
first, last = User.collate :first, :last # => [#<User id: 1 name: "Pat">, #<User id: 85 name: "Joe">]
avg, max, min = [4, 3, 1, 5, 2].collate :avg, :max, :min # => [3.0, 5, 1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment