Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@lanodan @j @Junes @SilverDeth @p @ElDeadKennedy @ceo_of_monoeye_dating
>but it reminds me that I really dislike the lack of early return in Elixir
Yeah, that can be very unintuitive at first. Same with implicit return when you try to log a result of a call the function retuns:
def func(var) when is_integer(var) do
var = var + 5
ret = process_var(var)
Logger.debug("#{__MODULE__} func/1 returning: #{inspect(ret)}")
ret
end
It's very easy to return the Logger output and then wonder why it doesn't work, especially for someone new that writes something like this:
var =
if asdf == true do
var = process_var(var)
Logger.debug("#{inspect(var)}")
else
nil