Skip to content

Instantly share code, notes, and snippets.

@danmayer
Created November 2, 2013 16:34
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 danmayer/7280801 to your computer and use it in GitHub Desktop.
Save danmayer/7280801 to your computer and use it in GitHub Desktop.
tap with each
# 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