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
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
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
(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