Skip to content

Commit 2c8dd2b

Browse files
committed
Replace mention of "container type" by "type of variable"
If you sav "my %h is Bag", your changing the type of the "%h" variable, which is *not* a container (aka, not a Scalar, Proxy or xxLexRef).
1 parent 603a7fb commit 2c8dd2b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

doc/Language/variables.pod6

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,28 @@ Examples:
4949
my @array = 1, 2, 3; # Array variable with three elements
5050
my %hash = London => 'UK', Berlin => 'Germany';
5151
52-
X<|is (container type)>
53-
The container type can be set with C<is> in a declaration.
52+
X<|is (type of variable)>
53+
The type to which the variable will be bound, can be set with C<is> in the
54+
declaration of the variable. Assuming we have a C<FailHash> class:
5455
5556
class FailHash is Hash {
5657
has Bool $!final = False;
5758
multi method AT-KEY ( ::?CLASS:D: Str:D \key ){
5859
fail X::OutOfRange.new(:what("Hash key"), :got(key), :range(self.keys)) if $!final && !self.EXISTS-KEY(key);
59-
callsame
60+
callsame # still not final, so do normal action from Hash
6061
}
6162
6263
method finalize() {
6364
$!final = True
6465
}
6566
}
6667
68+
One can then define a C<%h> variable using C<is>:
69+
6770
my %h is FailHash = oranges => "round", bananas => "bendy";
71+
72+
And then run the following code:
73+
6874
say %h<oranges>;
6975
# OUTPUT: «round␤»
7076
%h.finalize;

0 commit comments

Comments
 (0)