Key/Value Pair

Edit this Page

A Key/Value pair is a way to connect data with human friendly names. Often key-value pairs are held within a container. Key value pairs are used everywhere in programming.

  • first_name = "Zee" - Defines a ruby variable named first_name with the value "Zee". The key in this case is first_name.
  • { :first_name => "Zee", :last_name => "Spencer" } - Defines a ruby hash which contains two key value pairs: key :first_name with value "Zee" and key :lastname with value "Spencer".
  • <a href="http://google.com">Search!</a> - Defines an HTML link which contains a key href with the value "http://google.com".