What actually checks for for defimpl in Elixir?

Does "for" always check the type of the first argument in each function defined in the protocol?

EDIT (rephrasing): When a protocol method has only one argument, the implementation is determined based on the type of that single argument (direct or Any). When a protocol method has several arguments, which one is used to find the appropriate implementation? Is it always the first? Can I change it?

+4
source share
2 answers

Implementation is always determined based on the first argument.

, . def , , .

, , ( t), ( t impl_for!, , ).

A defimpl , , defprotocol. , , .

+5

Source: https://habr.com/ru/post/1569217/


All Articles