method

f = method() -- creates a method function

Optional arguments:

  • Associative
  • ClassArgument
  • SingleArgumentDispatch
  • Options
  • 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 also write:
              f X := (x) -> ...
    the effect of which happens to be the same as that of
              X#f := (x) -> ...

    See also Options, methods, and OptionsRegistry.

    Go to main index.

    Go to concepts index.