method CALL-ME
1 | role Callable |
1.1 | (Callable) method CALL-ME |
2 | role Enumeration |
2.1 | (Enumeration) method CALL-ME |
Documentation for method CALL-ME
assembled from the following types:
role Callable
From Callable
(Callable) method CALL-ME
method CALL-ME(Callable : |arguments)
This method is required for postfix:«( )» and postfix:«.( )». It's what makes an object actually call-able and needs to be overloaded to let a given object act like a routine. If the object needs to be stored in a &
-sigiled container, is has to implement Callable.
does Callablemy = A;say a(); # OUTPUT: «called»
Applying the Callable
role is not a requirement to make an object callable; if a class simply wants to add subroutine-like semantics in a regular scalar container, the submethod CALL-ME
can be used for that.
my = A.new: values => [4,5,6,7]say (2); # OUTPUT: «6»
role Enumeration
From Enumeration
(Enumeration) method CALL-ME
Defined as:
multi method CALL-ME(|)
Returns an Enumeration
instance given an enum value.
( mg => 1/1000, g => 1/1, kg => 1000/1 );say Mass(1/1000); # OUTPUT: mg