Hi, Dmitry!

how different will this expression be from: ### example 2

They are identical, regardless of the presence/absence of any code below.

To what extent is it correct to use one or another type of if statement?

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.

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

I recommend going through the Linux kernel coding style <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#placing-braces-and-spaces> 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 /opensips.cfg/ coding style? :-)

Best,

--
Liviu Chircu
www.twitter.com/liviuchircu  |www.opensips-solutions.com
OpenSIPS eBootcamp, Nov 6-17 |www.opensips.org/training
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to