Reputation: 4329
I suspect it's an elementary question, but it's been hard to find a succinct, canonical answer online.
From what little I understand;
Can anyone clarify?
Upvotes: 18
Views: 4862
Reputation: 23164
It require
s the given module and then calls the __using__/1
callback on it allowing the module to inject some code into the current context. See https://elixir-lang.org/getting-started/alias-require-and-import.html#use.
Example:
defmodule Test do
use Utility, argument: :value
end
is about the same as
defmodule Test do
require Utility
Utility.__using__(argument: :value)
end
Upvotes: 32