Skip to content

Commit 05cc5c4

Browse files
author
Jan-Olof Hendig
committed
Added docs for method 'dynamic'. jnthn++
1 parent d4b10c3 commit 05cc5c4

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

doc/Type/Hash.pod6

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,33 @@ returns C<(Mu)>.
611611
my Int %h2 = 'oranges' => 7; # (values must be of type Int)
612612
say %h2.of; # OUTPUT: «(Int)␤»
613613
614+
=head2 routine dynamic
615+
616+
Defined as:
617+
618+
method dynamic(--> Bool:D)
619+
620+
Returns C<True> if the invocant has been declared with the L<is dynamic|/routine/is dynamic>
621+
trait.
622+
623+
my %a;
624+
say %a.dynamic; # OUTPUT: «False␤»
625+
626+
my %b is dynamic;
627+
say %b.dynamic; # OUTPUT: «True␤»
628+
629+
If you declare a variable with the C<*> twigil C<is dynamic> is implied.
630+
631+
my %*b;
632+
say %*b.dynamic; # OUTPUT: «True␤»
633+
634+
Note that in the L<Scalar> case you have to use the C<VAR> method in
635+
order to get correct information.
636+
637+
my $s is dynamic = %('apples' => 5);
638+
say $s.dynamic; # OUTPUT: «False␤» (wrong, don't do this)
639+
say $s.VAR.dynamic; # OUTPUT: «True␤» (correct approach)
640+
614641
=head1 Subscript Adverbs
615642
616643
Some methods are implemented as adverbs on subscripts.

0 commit comments

Comments
 (0)