[top][index]
search for:

method -- make a new method function

f = method() -- creates a method function

The code above creates a method function which takes up to three arguments, looking up the appropriate method according to the classes of the arguments, with inheritance. To install a method for two arguments, (x,y), of classes X and Y, use code like this:

          f(X,Y) := (x,y) -> ...
where '...' represents the body of the function you wish to install. The syntax for one or three arguments is analogous. For a single argument x of class X, one could omit the parentheses, and write:
          f X := (x) -> ...
the effect of which happens to be the same as that of
          X#f := (x) -> ...

See also:

  • methods -- list methods
  • Optional arguments :

  • method(..., Associative => ...) -- allows associative methods to be created
  • method(..., Options => ...) -- method functions with optional arguments
  • method(..., SingleArgumentDispatch => ...) -- method functions with a variable number of arguments
  • method(..., TypicalValue => ...) -- specify return value type

  • [top][index]
    search for: