Advertisement
Guest User

Untitled

a guest
May 28th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. =head2 method keyof
  2.  
  3. Defined as:
  4.  
  5. method keyof
  6.  
  7. Usage:
  8.  
  9. Hash.keyof
  10.  
  11. Returns the type constraint for the keys of the invocant. For
  12. normal hashes the method returns the coercion type C<(Str(Any))>
  13. while for L<object hashes|/type/Hash#Object_hashes_and_type_constraints>
  14. the type used in the declaration of the C<Hash> is returned.
  15.  
  16. my %h1 = 'apples' => 3, 'oranges' => 7; # (no key type specified)
  17. say %h1.keyof; # (Any)
  18.  
  19. my %h2{Str} = 'oranges' => 7; # (keys must be of type C<Str>)
  20. say %h2.keyof; # (Str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement