Skip to content

Instantly share code, notes, and snippets.

@fenixbrassi
Created December 19, 2013 02:33
Show Gist options
  • Save fenixbrassi/8033454 to your computer and use it in GitHub Desktop.
Save fenixbrassi/8033454 to your computer and use it in GitHub Desktop.
Hash Practice
#hash
student = {}
student["First Name"] = “John”
student["Last Name"] = “Doe”
student["Age"] = 15
student["Subjects"] = {}
student["Subjects"][“Physics”] = 75
student["Subjects"][”Chemistry”] = 98
student["Subjects"][”Maths”] = 85
puts "First Name: #{student["First Name"]} Last Name: #{student["Last Name"]} Age: #{ student["Age"]} Subjects: #{ student["Subjects"].keys.map{|x| x + " "}.join } #{
student["Subjects"].keys.map{|x| x + ": " + student["Subjects"][x].to_s + " " }.join } "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment