Is it possible to assign a signature to a variable and then reuse it in different functions/methods?
I've found my $sig = :($a, $b);
but I don't know how I could use the variable as a signature in a function.
One way:
my $sig = :( $a, $b );
sub foo ( &function where { .signature ~~ $sig } ) {}
sub bar ( $p, $q ) {}
sub qux ( $waldo ) {}
foo &bar;
say "OK at line 10"; # OK at line 10
foo &qux; # Constraint type check failed ... line 12".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With