def() Usage Parameters 1. multimethod 2. signature Return value Version History See also

def()

A JSFunction that defines a new method and adds it to a multimethod.

Usage

def(multimethod, signature, implementation)
def(multimethod, signature, implementation, callsNext)

Parameters

# Parameter Required? Type Default
1 multimethod yes TGeneric.md
2 signature yes JSArray<TAny>
3 implementation yes JSFunction
4 callsNext no JSBoolean false

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

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
def() 1.0

See also