Multiple dispatch
Multiple dispatch is a method-selection mechanism that chooses an implementation based on the types of multiple arguments.
Julia as a Second Language
Multiple dispatch is a method-selection mechanism that chooses an operation implementation based on the types of all dispatched arguments.
- How it is used
- Selects behavior for game-combat operations according to both participants’ types.
- How deep it goes
- Works through method signatures, inspection, missing-method errors, and runtime selection without detailing dispatch implementation internals.
- Examples
- Uses REPL battles between archers and knights, a missing knight-versus-knight method, and a battle outcome function.
- What you can do after
- Build it from scratch by adding matchup-specific Julia methods and inspecting which signatures are available.
Read how Julia as a Second Language explains multiple dispatch →
Data-Oriented Programming: Reduce software complexity
Multiple dispatch is a dispatch mechanism that selects an implementation based on the types of several arguments.
- How it is used
- Uses multimethods to select behavior from multiple arguments represented as generic maps.
- How deep it goes
- Explains dispatch signatures, validation, emitted values, method wiring, calls, and ordering, while deferring dynamic dispatch.
- Examples
- Demonstrates animal greetings selected by dog, cat, or cow types combined with French or English language maps.
- What you can do after
- Build it from scratch by defining a dispatch function, registering methods, and calling the multimethod like a regular function.
Read how Data-Oriented Programming: Reduce software complexity explains multiple dispatch →
Related concepts
- Juliaused by · Julia is a high-level, high-performance programming language designed for numerical, scientific, and technical computing.
- function overloadingcontrasts with · Function overloading is defining multiple callable operations with the same name but different parameter signatures, with behavior selected according to the call.
- polymorphic dispatchuses · Polymorphic dispatch is runtime selection of an operation implementation based on a call's arguments, function value, or context.
- promote_ruleused by · promote_rule is a Julia function whose methods specify the common type to which two types are promoted.
- polymorphismkind of · Polymorphism is a programming-language capability that lets a common interface or operation work with values of different types while allowing behavior to vary by type or implementation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

