around() Usage Parameters 1. multimethod 2. signature 3. implementation Return value Version History See also

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 example JSString or TNumber
  • A JavaScript class
  • A trait
  • A value

3. implementation

The method to add.

Around methods are given a next function as the first argument before any actual arguments for the multimethod. This next function calls either the (first) matching primary method or the next matching around 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