method count

Documentation for method count assembled from the following types:

class Code

From Code

(Code) method count

Defined as:

method count(Code:D: --> Real:D)

Returns the maximum number of positional arguments that may be passed when calling the code object. For code objects that can accept any number of positional arguments (that is, they have a slurpy parameter), count will return Inf. Named parameters do not contribute.

sub argless() { }
sub args($a$b?{ }
sub slurpy($a$b*@c{ }
say &argless.count;             # OUTPUT: «0␤» 
say &args.count;                # OUTPUT: «2␤» 
say &slurpy.count;              # OUTPUT: «Inf␤»

class ForeignCode

From ForeignCode

(ForeignCode) method count

method count()

Returns the number of arguments the enclosed code needs.

class Signature

From Signature

(Signature) method count

method count(Signature:D: --> Real:D)

Returns the maximal number of positional arguments which can be bound to the signature. Returns Inf if there is a slurpy positional parameter.