<div dir="ltr"><div>Hi,</div><div>I have a function like this:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Fira Code","Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Fira Code","Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(220,220,170)">get_nas_from_conf</span><span style="color:rgb(212,212,212)">() -></span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">case</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">get_radius_host</span><span style="color:rgb(212,212,212)">() </span><span style="color:rgb(197,134,192)">of</span></div><div><span style="color:rgb(212,212,212)">        {ok, </span><span style="color:rgb(156,220,254)">Server</span><span style="color:rgb(212,212,212)">} -></span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(197,134,192)">case</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">get_radius_port</span><span style="color:rgb(212,212,212)">() </span><span style="color:rgb(197,134,192)">of</span></div><div><span style="color:rgb(212,212,212)">                {ok, </span><span style="color:rgb(156,220,254)">Port</span><span style="color:rgb(212,212,212)">} -></span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(197,134,192)">case</span><span style="color:rgb(212,212,212)"> </span><span style="color:rgb(220,220,170)">get_radius_secret</span><span style="color:rgb(212,212,212)">() </span><span style="color:rgb(197,134,192)">of</span></div><div><span style="color:rgb(212,212,212)">                        {ok, </span><span style="color:rgb(156,220,254)">Secret</span><span style="color:rgb(212,212,212)">} -></span></div><div><span style="color:rgb(212,212,212)">                            {</span><span style="color:rgb(156,220,254)">Server</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">Port</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">Secret</span><span style="color:rgb(212,212,212)">};</span></div><div><span style="color:rgb(212,212,212)">                        </span><span style="color:rgb(156,220,254)">E</span><span style="color:rgb(212,212,212)"> -> </span><span style="color:rgb(156,220,254)">E</span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)">;</span></div><div><span style="color:rgb(212,212,212)">                </span><span style="color:rgb(156,220,254)">E</span><span style="color:rgb(212,212,212)"> -></span></div><div><span style="color:rgb(212,212,212)">                    </span><span style="color:rgb(156,220,254)">E</span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)">;</span></div><div><span style="color:rgb(212,212,212)">        </span><span style="color:rgb(156,220,254)">E</span><span style="color:rgb(212,212,212)"> -></span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(156,220,254)">E</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)">.</span></div></div></div></div><div><br></div><div>Which is the best way to write this kind of function?</div><div><br></div><div>I'd like to have a with operator like in Elixir, to rewrite my function in this way:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Fira Code","Droid Sans Mono","monospace",monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(220,220,170)">get_nas_from_conf</span><span style="color:rgb(212,212,212)">() -></span></div><div><span style="color:rgb(212,212,212)">    <span style="color:rgb(212,212,212)"></span><span style="color:rgb(197,134,192)">with</span> {ok, </span><span style="color:rgb(156,220,254)">Server</span><span style="color:rgb(212,212,212)">} <- </span><span style="color:rgb(220,220,170)">get_radius_host</span><span style="color:rgb(212,212,212)">(),</span></div><div><span style="color:rgb(212,212,212)">         {ok, </span><span style="color:rgb(156,220,254)">Port</span><span style="color:rgb(212,212,212)">} = </span><span style="color:rgb(220,220,170)">get_radius_port</span><span style="color:rgb(212,212,212)">(),</span></div><div><span style="color:rgb(212,212,212)">         {ok, </span><span style="color:rgb(156,220,254)">Secret</span><span style="color:rgb(212,212,212)">} = </span><span style="color:rgb(220,220,170)">get_radius_secret</span><span style="color:rgb(212,212,212)">() -></span></div><div><span style="color:rgb(212,212,212)">            {</span><span style="color:rgb(156,220,254)">Server</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">Port</span><span style="color:rgb(212,212,212)">, </span><span style="color:rgb(156,220,254)">Secret</span><span style="color:rgb(212,212,212)">};</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">catch</span></div><div><span style="color:rgb(212,212,212)">        {error, </span><span style="color:rgb(156,220,254)">_Reason</span><span style="color:rgb(212,212,212)">} = </span><span style="color:rgb(156,220,254)">E</span><span style="color:rgb(212,212,212)"> -></span></div><div><span style="color:rgb(212,212,212)">            </span><span style="color:rgb(156,220,254)">E</span></div><div><span style="color:rgb(212,212,212)">    </span><span style="color:rgb(197,134,192)">end</span><span style="color:rgb(212,212,212)">.</span></div></div></div><div><br></div><div>Any suggestion?</div><div><br></div><div>-- <br><div dir="ltr" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>GL<br><a href="https://meox.github.io" target="_blank">https://www.meocci.it</a><br></div></div></div></div></div></div></div>