Re: [elixir-core:12033] [Proposal] Conveniences for casting environment variables

2025-02-18 Thread dave.lu...@gmail.com
g room to make this happen. >> >> -a >> >> On Tue, Feb 18, 2025 at 11:31 AM Zach Daniel >> wrote: >> >>> Hm…that makes sense. I’d maintain that it should end in a `!` for >>> clarity though, even if there is no non-raising variant. >>&g

[elixir-core:12024] [Proposal] Conveniences for casting environment variables

2025-02-18 Thread dave.lu...@gmail.com
In Elixir applications, config/runtime.exs is often used to parse environment variables from System.get_env2/ and friends, and convert into Application configuration. Since environment variables can only be strings, it is often necessary to cast from string values into booleans and integer valu

Re: [elixir-core:12029] [Proposal] Conveniences for casting environment variables

2025-02-18 Thread dave.lu...@gmail.com
(var) when is_boolean(var) do > var > end > > defp to_boolean(var) do > String.downcase(to_string(var)) in ["1", "true", "on", "yes", "y"] > end > > > On Tuesday, February 18, 2025 at 5:07:50 PM UTC+1 dave.lu

[elixir-core:12025] Re: [Proposal] Conveniences for casting environment variables

2025-02-18 Thread dave.lu...@gmail.com
could also see separate functions for booleans and integers, but either works On Tuesday, February 18, 2025 at 11:07:50 AM UTC-5 dave.lu...@gmail.com wrote: > In Elixir applications, config/runtime.exs is often used to parse > environment variables from System.get_env2/ and friends, an