Created
October 1, 2008 00:18
-
-
Save nkpart/13992 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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