create-method ( class generic -- method )
Factor documentation > Factor handbook > The language > Objects > Generic words and methods > Generic word introspection
Prev:define-simple-generic ( word effect -- )
Next:lookup-method ( class generic -- method )


Vocabulary
generic

Inputs and outputs
classa class
generica generic
methoda method


Word description
Creates a method or returns an existing one. This is the runtime equivalent of M:.

Notes
To define a method, pass the output value to define.

See also
lookup-method, ?lookup-method

Definition
USING: classes.private kernel words ;

IN: generic

: create-method ( class generic -- method )
2dup ?lookup-method dup
[ 2nip dup reset-generic ]
[ drop [ <method> dup ] 2keep reveal-method reset-caches ]
if ;