Created
November 2, 2013 16:34
-
-
Save danmayer/7280801 to your computer and use it in GitHub Desktop.
tap with each
This file contains 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
# do this opposed to each_with_object or inject | |
# from http://phrogz.net/tap-vs-each_with_object | |
by_id = {}.tap{ |h| items.each{ |item| h[item.id] = item } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment