Hash

From AN!Wiki
Jump to: navigation, search

 AN!Wiki :: Hash

A hash table, also known as a dictionary, is a programmatic way of storing elements in a way that allows their retrieval by using a named key. This allows a program to not worry about where in the hash an element is at any given time as it's position is irrelevant to it's retrieval.

  • Hash tables are generally slower than arrays.

Hash tables are often expressed in the following format:

  • Creating a hash table with four key/value pairs.
hash=(
       some_key    => "first_element",
       another_key => "foobar",
       this_key    => 12,
       that_key    => "30.5"
)
  • Retrieving one of the elements by using the associated key name.
print hash{that_key};   # Would print "30.5".

In Perl, hashes are prefixed with the '%' symbol.

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Us: Alteeve's Niche! Support: Mailing List IRC: #clusterlabs on Freenode   © Alteeve's Niche! Inc. 1997-2019
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.
Personal tools
Namespaces

Variants
Actions
Navigation
projects
Toolbox