Last active
June 29, 2017 22:00
-
-
Save dogbert17/8260285b5e63b01849324ac775dd4afe to your computer and use it in GitHub Desktop.
dynamic
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=head2 routine dynamic | |
Defined as: | |
method dynamic(Array:D: --> Bool:D) | |
Returns C<True> if the invocant has been declared with the L<is dynamic|/routine/is dynamic> | |
trait. | |
my @a; | |
say @a.dynamic; # OUTPUT: «False» | |
my @b is dynamic; | |
say @b.dynamic; # OUTPUT: «True» | |
If you declare a variable with the C<*> twigil C<is dynamic> is implied. | |
my @*b; | |
say @*b.dynamic; # OUTPUT: «True» | |
Note that in the L<Scalar> case you have to use the C<VAR> method in | |
order to get correct information. | |
my $s is dynamic = [1, 2, 3]; | |
say $s.dynamic; # OUTPUT: «False» (wrong, don't do this) | |
say $s.VAR.dynamic; # OUTPUT: «True» (correct approach) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment