Destructuring assignment for object
Currently there is no way to destruct object on assignment.
my (:$key, :$value) = a => 1; # not what you think
# $key is :a(1)
# $value is (Any)
This is weird, since destructing array works both in block signature and in assignment.
In Raku, destructuring is performed by binding (thus "signature binding"):
my (:$key, :$value) := a => 1;
say $key; # a
say $value; # 1
But how is ths usable?
my ($a, $b) = 1, 2
I don't remember this documented, but := is much better (to catch errors):
my ($a, $b) := 1, 2, 3;
Too many positionals passed to '<unit>'; expected 2 arguments but got 3
in block <unit> at <unknown file> line 1
But how is ths usable?
my ($a, $b) = 1, 2
That's list assignment. I suggest looking up some docs on assignment vs binding; Raku offers both, and they are quite different in nature.
The official docs (docs.raku.org) only has example for single-value binding (my $a = $b). Now I understand it better.