Hylke Alons good point, thanks! But this only applies to my proposal for 
System.get_env/3. 

But I think we still need some discussion around System.fetch_env/1 and 
System.fetch_env!. I assume that the use cases for these functions are 
quite common, we usually want to raise an error in case a environment 
variable is missing.

What do you think?

Thanks, 
Thiago

Em terça-feira, 18 de dezembro de 2018 15:03:49 UTC-2, Hylke Alons escreveu:
>
> It has been proposed various times.
>
> Checkout https://github.com/elixir-lang/elixir/pull/7172
>
> On Tuesday, 18 December 2018 17:09:12 UTC+1, [email protected] wrote:
>>
>> Hi,
>>
>> Would be great if we had in the System module functions similar to those 
>> that we have right now in the Application module.
>>
>> `System.get_env/2` could accept a default value similar to 
>> `Application.get_env/3`. I always find myself using System.get_env("VAR") 
>> || "DEFAULT VALUE".
>>
>> And we could have `System.fetch_env/1` and `System.fetch_env!/1`. The 
>> fetch_env!/1 I would use a lot. Normally you want to raise an error if the 
>> variable does not exists and would be great if the already existed an 
>> function to do that. Right we have to use Map.fetch! 
>> `Map.fetch!(System.get_env(), "VAR")` or create our own custom function 
>> that raises an error. I think that as it is a common use case would make 
>> sense to include this functions in the language.
>>
>> What do you guys think?
>>
>> Thanks,
>> Thiago
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" 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-core/be01fecc-08f6-474b-909e-a0717ce9b874%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to