You can also store it into a map that is returned from a function like this:
def Consts, do: %{
AUDIT_ENTITY_REV_TYPE_DELETE: 301001,
AUDIT_ENTITY_REV_TYPE_INSERT: 301002,
...
}
Being a constant object in the code with no variables it gets constructed fast, however usual things in Erlang/Elixir get optimized into the bytecode so no construction actually takes place and it gets shared easily, I’m not sure if maps do that however.
Overall @michalmuskala method is usually best, no construction time at all, however the lookup time can be linear in a match set like that so a map might be faster in lookup speed.






















