Skip to content

Instantly share code, notes, and snippets.

@greenplastik
Created June 29, 2010 18:36
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 greenplastik/457598 to your computer and use it in GitHub Desktop.
Save greenplastik/457598 to your computer and use it in GitHub Desktop.
# Let's say I have this the following array of strings that are usually dynamically created:
array = ["one", "two", "three", "four", "five"]
# I would like to to use this array to create the following hash, using the items from the array as the keys and then also using them to set the value by referencing another hash, as follows:
hsh = {"one" => some_other_hash[:one], "two" => some_other_hash[:two], "three" => some_other_hash[:three], "four" => some_other_hash[:four], "five" => some_other_hash[:five]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment