How does dispatching to protocol implementations work when the functions have more than 1 argument?

This has been confounding me for a while. I’m curious to know how do protocols (and their implementations) work for functions with more than ONE argument? Because the execution flow gets dispatched based on the data-type involved, I don’t follow how Elixir would “know” where to send execution for functions that contain multiple inputs (and thus multiple data-types). Looking over the defprotocol and defimpl in the core, I can see that usually the functions are simple and have only 1 argument, and the implementations clearly state something like for: Integer or similar, but some (like Enumerable ) are more complex.

Thanks for any explanations!

When you call a protocol function, the data type of the first argument is always the data type that is used for dispatch.