When one operation must vary by data type, arrows/multimethods supplies JavaScript multimethods without forcing every implementation into one module. Create a dispatch function, initialize the multimethod with multi, then attach implementations with method. section 13.2
A dispatch function handles three jobs:
- Defines the multimethod signature. section 13.2
Greeting by animal type
Initialize greet from greetDispatch, then register dog, cat, and cow handlers with method("dog", greetDog)(greet) and equivalent calls. Invoke greet(myDog), greet(myCat), or greet(myCow) like an ordinary function; add a default handler for unmatched types such as horse.
