3 ms·
What do you mean? It wouldn't be "if". You'd just have function hit(p::Player, m::Goblin) ... end function hit(p::Player, o::Ogre) ...
by ced 8y ago
What do you mean? It wouldn't be "if". You'd just have
function hit(p::Player, m::Goblin)
...
end
function hit(p::Player, o::Ogre)
...
end
In Julia, there's limited inheritance, so you could group monsters in a hierarchy to limit the redundancy (eg. Goblin <: Monster <: Creature). Or you can use multiple dispatch like a trait system, to get even greater flexibility.