Skip to content

Instantly share code, notes, and snippets.

@nkpart
Created October 1, 2008 00:18
Show Gist options
  • Save nkpart/13992 to your computer and use it in GitHub Desktop.
Save nkpart/13992 to your computer and use it in GitHub Desktop.
module Enumerable
def name_please &blk
inject({}) do |accum, elem|
accum[elem] = blk.call(elem)
accum
end
end
end
[1,2].name_please { |x| "#{x} value" } # <= { 1 => "1 value", 2 => "2 value" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment