Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added docs for method keyof in class Hash. lizmat++, jnthn++
  • Loading branch information
Jan-Olof Hendig committed May 28, 2016
1 parent 5654705 commit 32541e4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions doc/Type/Hash.pod
Expand Up @@ -340,6 +340,28 @@ C<(Any)>.
say %h2.default; # 1
say %h2{'apples'} + %h2{'bananas'}; # 4
=head2 method keyof
Defined as:
method keyof
Usage:
Hash.keyof
Returns the type constraint for the keys of the invocant. For
normal hashes the method returns the coercion type C<(Str(Any))>
while for L<object hashes|/type/Hash#Object_hashes_and_type_constraints>
the type used in the declaration of the C<Hash> is returned.
my %h1 = 'apples' => 3, 'oranges' => 7; # (no key type specified)
say %h1.keyof; # (Str(Any))
my %h2{Str} = 'oranges' => 7; # (keys must be of type Str
say %h2.keyof; # (Str)
%h2{3} = 'apples'; # throws exception of type X::TypeCheck::Binding
=head1 Subscript Adverbs
Some methods are implemented as adverbs on subscripts.
Expand Down

0 comments on commit 32541e4

Please sign in to comment.