January 2020
Intermediate to advanced
532 pages
13h 31m
English
Julia's dispatch mechanism is unique not only because of its multiple dispatch features, but also the way that it treats function arguments dynamically when deciding where to dispatch.
Let's say we want to randomly pick two objects and check whether they collide. We can define the function as follows:
# randomly pick two things and checkfunction check_randomly(things) for i in 1:5 two = rand(things, 2) collide(two...) endend
Let's run it and see what happens:

We can see that different collide methods are called depending on the types of the arguments that are passed in the two variable.
Read now
Unlock full access