Skip to content

Instantly share code, notes, and snippets.

@dogbert17
Last active June 29, 2017 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dogbert17/8260285b5e63b01849324ac775dd4afe to your computer and use it in GitHub Desktop.
Save dogbert17/8260285b5e63b01849324ac775dd4afe to your computer and use it in GitHub Desktop.
dynamic
=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