Documentation for method
type_captures assembled from the following types:
method type_captures(Parameter: --> List)
Returns a list of variable names of type captures associated with this parameter. Type captures define a type name within the attached code, which is an alias to the type gleaned from the argument during a call.
sub a(::T ::U )a(8); # OUTPUT: «(Int)␤»say .signature.params.type_captures; # OUTPUT: «(T U)␤»sub b()a(8); # OUTPUT: «Int␤»
The type used may change from call to call. Once they are defined, type captures can be used wherever you would use a type, even later in same the signature:
sub c(::T , T , ) ;c(4, 5, 6); # OKc(4, 5, "six"); # Fails when assigning to $zz, wants Int not Strc("four", 5, "six"); # Fails when binding $y, wants Str, not Int
Type captures may be used at the same time as type constraints.
sub d(::T Numeric , T ) ;d(4, 5); # OKd(4e0, 5e0); # OKd(4e0, 5); # Fails when binding $yd("four", "five"); # Fails when binding $x