Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Last active December 20, 2015 04:19
Show Gist options
  • Save rubysolo/6070493 to your computer and use it in GitHub Desktop.
Save rubysolo/6070493 to your computer and use it in GitHub Desktop.
collection = [:a, :b, :c]
collection.each_with_index.each_with_object({}) do |(item, index), hash|
hash[item] = index
end
# => {:a=>0, :b=>1, :c=>2}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment