The following line declares a variable and binds it to the number on the right-hand side.
my $a := 42;
The effect is that $a
is not a Scalar
, but an Int
, as can be seen by
say $a.VAR.^name;
My question is, can I bind multiple variables in one declaration? This doesn't work:
my ($a, $b) := 17, 42;
because, as can be seen using say $a.VAR.^name
, both $a
and $b
are Scalar
s now. (I think I understand why this happens, the question is whether there is a different approach that would bind both $a
and $b
to given Int
s without creating Scalar
s.)
Furthermore, is there any difference between using :=
and =
in this case?