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
- Uses multiple dispatch to express behavior for combinations of Julia argument types.
- How deep it goes
- Explains method attachment, inspection, missing-method errors, subtype matching, and runtime selection through worked examples.
- Examples
- Uses warrior attacks, a knight-versus-knight method, and a battle that accepts Warrior subtypes.
- What you can do after
- Apply it in Julia by defining and inspecting methods for different argument types and diagnosing missing-method errors.
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 →
What to know first
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
Related concepts
- Juliaused by · Julia is a high-level, high-performance programming language designed for numerical, scientific, and technical computing.
- polymorphic dispatchuses · Polymorphic dispatch is runtime selection of an operation implementation based on a call's arguments, function value, or context.
- function overloadingcontrasts with · Function overloading is a programming-language feature in which one name denotes multiple callable signatures or implementations distinguished by parameter types or forms, with applicability determined by the call or context.
- polymorphismkind of · Polymorphism is a programming-language capability that lets a common operation or interface work with values of different types, with behavior or implementation determined by the type or value.
- promote_ruleused by · promote_rule is a Julia function whose methods specify the common type to which two types are promoted.
Questions about multiple dispatch
What is multiple dispatch?
Multiple dispatch is a method-selection mechanism that chooses an implementation based on the types of multiple arguments.
Which Manning books explain multiple dispatch?
Julia as a Second Language and Data-Oriented Programming: Reduce software complexity.
What should I know before learning multiple dispatch?
Manning books that teach multiple dispatch usually introduce array first.
What is the difference between multiple dispatch and single dispatch?
Multiple dispatch is a method-selection mechanism that chooses an implementation based on the types of multiple arguments. Single dispatch is a method-selection mechanism that chooses an implementation based on the type or value of one receiver or argument.
What is multiple dispatch a kind of?
Multiple dispatch is a kind of polymorphism. Polymorphism is a programming-language capability that lets a common operation or interface work with values of different types, with behavior or implementation determined by the type or value.
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.

