January 2020
Intermediate to advanced
532 pages
13h 31m
English
One of the most useful features with type parameters is that they can be used to enforce type consistency.
Let's say we want to create a new function that groups two Thing objects together. As we don't really care about what concrete types are passed, we can just write a single function that does the work:
function group_anything(A::Thing, B::Thing) println("Grouped ", A, " and ", B)end
We can also run some trivial tests quickly to ensure that all four combinations of spaceships and asteroids are working:

Read now
Unlock full access