Top 1,000 Features Creators Resources Blog Explorer Download
GitHub icon

Multiple Dispatch

< >
Example from 1 languages: Julia
collide_with(x::Asteroid, y::Asteroid) = ... # deal with asteroid hitting asteroid collide_with(x::Asteroid, y::Spaceship) = ... # deal with asteroid hitting spaceship collide_with(x::Spaceship, y::Asteroid) = ... # deal with spaceship hitting asteroid collide_with(x::Spaceship, y::Spaceship) = ... # deal with spaceship hitting spaceship
Example from 1 languages: Common Lisp
(defmethod collide-with ((x asteroid) (y asteroid)) ;; deal with asteroid hitting asteroid ) (defmethod collide-with ((x asteroid) (y spaceship)) ;; deal with asteroid hitting spaceship ) (defmethod collide-with ((x spaceship) (y asteroid)) ;; deal with spaceship hitting asteroid ) (defmethod collide-with ((x spaceship) (y spaceship)) ;; deal with spaceship hitting spaceship )
*

Languages with Multiple Dispatch include Julia, Smalltalk, Common Lisp, Dylan

*

Languages without Multiple Dispatch include JavaScript, Elixir, Speedie

*

View all concepts with or missing a hasMultipleDispatch measurement

*

Read more about Multiple Dispatch on the web: 1.

View source

- Build the next great programming language About Acknowledgements Extensions Day 630 Donate feedback@pldb.io