4 ms·
Also disagree with the author! > You should not use else to handle potential errors (when using with) Yes you should! Otherwise the with statement could retur
by joshribakoff 5y ago
Also disagree with the author!
> You should not use else to handle potential errors (when using with)
Yes you should! Otherwise the with statement could return something that is not :ok and also not :error. I think therefore it’s good practice to put else {:error, error} -> {:error, error} especially because Elixir is not strongly typed so this helps constrain the possible types the statement can return. If you omit the else, your construct can return any number of types from values produced downstream.