around()
A JSFunction
that adds a qualified method to a multimethod that wraps
around the primary method(s).
Usage
around(multimethod, signature, implementation)
Parameters
# | Parameter | Required? | Type | Default |
---|---|---|---|---|
1 | multimethod | yes | TGeneric | |
2 | signature | yes | JSArray<TAny> | |
3 | implementation | yes | JSFunction |
1. multimethod
The multimethod for which a new method shall be defined.
2. signature
The new method's signature. It's an array containing zero or more items.
A signature item can be:
- A predicate function (function returning a
JSBoolean
) - A
TType
, for exampleJSString
orTNumber
- A JavaScript class
- A trait
- A value
3. implementation
The method to add.
Around
methods are given anext
function as the first argument before any actual arguments for the multimethod. Thisnext
function calls either the (first) matching primary method or the next matchingaround
method.
Return value
The JSFunction
used to create the method (implementation
). This reference
can be used to remove the method with undef().
Version History
Feature | Since version |
---|---|
around() | 1.0 |
See also
- API: undef