<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<div class="moz-cite-prefix">Hi, Dmitry!<br>
</div>
<div class="moz-cite-prefix"><br>
</div>
<blockquote type="cite"
cite="mid:CAJUEF2t6j50mVfEPXON8R4owi1Znf72hN7_1B-Lu39hUS6D4TA@mail.gmail.com">how
different will this expression be from:
### example 2</blockquote>
<p>They are identical, regardless of the presence/absence of any
code below. </p>
<blockquote type="cite"
cite="mid:CAJUEF2t6j50mVfEPXON8R4owi1Znf72hN7_1B-Lu39hUS6D4TA@mail.gmail.com">
<p style="margin:0px">
</p>
<p style="margin:0px">To what extent is it correct to use one or
another type of if statement?</p>
</blockquote>
<p>It's not about correctness, rather readability. Example 1 uses 3
LoC, while example 2 uses only LoC and it more readable, thanks to
the absence of the braces.</p>
<blockquote type="cite"
cite="mid:CAJUEF2t6j50mVfEPXON8R4owi1Znf72hN7_1B-Lu39hUS6D4TA@mail.gmail.com">
<p style="margin:0px">I understand that if we have to use else,
then only the first option will suit us, but here it’s more
about a single if.. thanks</p>
</blockquote>
<p>I recommend going through the <a
href="https://www.kernel.org/doc/html/v4.10/process/coding-style.html#placing-braces-and-spaces">Linux
kernel coding style</a> docs, there is a "placing braces and
spaces" section, which includes several if-statement examples,
with braces, "else" blocks, etc. Why not borrow the same ideas
for our own <i>opensips.cfg</i> coding style? :-)<br>
</p>
<p>Best,<br>
</p>
<pre class="moz-signature" cols="72">--
Liviu Chircu
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/liviuchircu">www.twitter.com/liviuchircu</a> | <a class="moz-txt-link-abbreviated" href="http://www.opensips-solutions.com">www.opensips-solutions.com</a>
OpenSIPS eBootcamp, Nov 6-17 | <a class="moz-txt-link-abbreviated" href="http://www.opensips.org/training">www.opensips.org/training</a></pre>
</body>
</html>