1: The thing with the constants is I get a compile time check that I am referencing the exact string/atom.
Say, Module A i reference :less_than and in module B :less_then (typo). This error will only be shown (silently) at runtime. 2: This seems like a lot of boilerplate as I may have 20 + of those filters > On 24 May 2016, at 12:02, José Valim <[email protected]> wrote: > > > 1: That doesn't solve the issue of sharing constants between modules > > You can just use atoms in both places. > > 2: I use strings because I match it against user supplied input that I do not > want to convert to atoms > > You can write a straight-forward conversion function: > > def from_user_input("less_than"), do: :less_than > def from_user_input("greater_than"), do: :greater_than > ... > -- You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-talk/A545AC8E-2F91-430D-8862-7DD08B6EE0D2%40gmail.com. For more options, visit https://groups.google.com/d/optout.
