Skip to content

Instantly share code, notes, and snippets.

@rvbsanjose
Created October 7, 2012 10:23
Show Gist options
  • Save rvbsanjose/3847782 to your computer and use it in GitHub Desktop.
Save rvbsanjose/3847782 to your computer and use it in GitHub Desktop.
Hashed table
def hashed_table
hashed_data_table = Array.new(4)
hashed_data_table[0] = ["Number", "Name", "Position", "Points per Game"]
hashed_data_table[1] = ["12", "Joe Schmo", "Center", "[14, 32, 7, 0, 23]"]
hashed_data_table[2] = ["9", "Ms. Buckets", "Point Guard", "[19, 0, 11, 22, 0]"]
hashed_data_table[3] = ["31", "Harvey Kay", "Shooting Guard", "[0, 30, 16, 0, 25]"]
hashed_data_table[4] = ["18", "Sally Talls", "Power Forward", "[18, 29, 26, 31, 19]"]
hashed_data_table[5] = ["22", "MK DiBoux", "Small Forward", "[11, 0, 23, 17, 0]"]
index = 1
player_info = []
while hashed_data_table[index]
player_info << Hash[hashed_data_table[0].zip(hashed_data_table[index])]
index += 1
end
player_info[3]["Name"] # Returns Sally Talls
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment