Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active May 28, 2016 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/447575b42b268b3d562a020bb754fadd to your computer and use it in GitHub Desktop.
Save dogbert17/447575b42b268b3d562a020bb754fadd to your computer and use it in GitHub Desktop.
Attempt to document method keyof in class Hash
=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 C<Str>)
say %h2.keyof; # (Str)
@lizmat
Copy link

lizmat commented May 28, 2016

say %h1.keyof; # (Any) # Str(Any) ??

@dogbert17
Copy link
Author

Fixed, that part was from yesterday, before you and jnthn worked your magic :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment