September 2017
Beginner
402 pages
9h 52m
English
In the array, indexes are integer numbers starting from zero. Hashes are another structural type of data in Perl 6 that can be treated as arrays whose indices are strings.
Hashes use the % sigil. Other names for hashes from various programming languages are associative arrays, dictionaries or dicts, and maps. Hashes are very useful when you need to keep a few values together. For example, take a look at the following code snippet:
my %city = name => 'London', country => 'gb', latitude => 51.52, longitude => 0, area => 1577, inhabitants => 8_700_000;
Elements of the hash are pairs, which are in turn two things—the key and the value. In this example, keys of the %city hash are name, country, and so on, and their values are London
Read now
Unlock full access