Skip to content

Instantly share code, notes, and snippets.

@bartocc
Created January 7, 2011 10:02
Show Gist options
  • Save bartocc/769311 to your computer and use it in GitHub Desktop.
Save bartocc/769311 to your computer and use it in GitHub Desktop.
list = ["a", "aa", "aaa"]
# --------
list.inject({}) do |hash, v|
hash[v] = v.length
hash
end
# VS
Hash[list.map {|v| [v, v.length]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment