@@ -730,8 +730,9 @@ items:
730
730
say [@a, 3, 4].perl; # OUTPUT: «[[1, 2], 3, 4]»
731
731
say [|@a, 3, 4].perl; # OUTPUT: «[1, 2, 3, 4]»
732
732
733
- L < List|/type/List > type can be explicitly created from an array literal declaration without a coercion
734
- coercion from Array, using B < is > L < trait|/language/traits > on declaration.
733
+ L < List|/type/List > type can be explicitly created from an array
734
+ literal declaration without a coercion from Array, using B < is >
735
+ L < trait|/language/traits > on declaration.
735
736
736
737
my @a is List = 1, 2; # a List, not an Array
737
738
# wrong: creates an Array of Lists
@@ -792,8 +793,16 @@ a coercion, using B<is> L<trait|/language/traits> on declaration:
792
793
my %mix is Mix; # Mix
793
794
my mix-hash is MixHash; # MixHash
794
795
795
- # This is wrong: creates a Hash of Mixes, not Mix
796
+
797
+ Note that using a usual type declaration with a hash sigil creates a
798
+ typed Hash, not a particular type:
799
+
800
+ # This is wrong: creates a Hash of Mixes, not Mix:
796
801
my Mix %mix;
802
+ # Works with $ sigil:
803
+ my Mix $mix;
804
+ # Can be typed:
805
+ my Mix[Int] $mix-of-ints;
797
806
798
807
= head3 Regex literals
799
808
0 commit comments