Skip to content

Commit

Permalink
Update Hash.pod6
Browse files Browse the repository at this point in the history
  • Loading branch information
tisonkun committed Oct 12, 2017
1 parent 09f25db commit feba7d3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions doc/Type/Hash.pod6
Expand Up @@ -129,10 +129,11 @@ Note: The same pitfalls explained about C<{}> sometimes creating Block's also
apply to C<:{}>. At this time there is no C<%()> version for creating non-string
keys.
Hash keys are stored as L<Str> values in a normal hash. In many cases this is
sufficient, but sometimes you want the hash to preserve the objects you are using
as keys I<as the *exact* objects you are providing to the hash to use as keys>.
In these moments you want an object hash!
X<|object hash>X<|:{}>
Now if you want to define a hash to preserve the objects you are using
as keys I<as the *exact* objects you are providing to the hash to use as keys>,
then object hash is what you are looking for.
my %intervals{Instant};
my $first-instant = now;
Expand All @@ -147,7 +148,8 @@ In these moments you want an object hash!
}
This example uses an object hash that only accepts keys of type L<Instant> to
implement a rudimentary, yet type-safe, logging mechanism. We utilize a named L<state|/language/variables#The_state_Declarator>
implement a rudimentary, yet type-safe, logging mechanism. We utilize a named
L<state|/language/variables#The_state_Declarator>
variable for keeping track of the previous C<Instant> so that we can provide an interval.
The whole point of object hashes is to keep keys as objects-in-themselves.
Expand Down

0 comments on commit feba7d3

Please sign in to comment.