5.5. Overview

Example 5-4. examples/hash/hash.p6

#!/usr/bin/perl6

# creating hashes
my %h1 = (first => '1st', second => '2nd');
my %h2{'a', 'b'} = ('A', 'B');

if (%h2{'a'}.defined) {
    say "the value of 'a' is defined";
}
if (%h2<b>.defined) {
    say "the value of 'b' is defined";
}

if (%h2.exists('a')) {
    say "the key 'a' exists in h2";
}

say %h1<first>;

say %h2.delete('a');
say %h2.delete('a');