Skip to main content
added 34 characters in body
Source Link
Deduplicator
  • 9.3k
  • 5
  • 33
  • 53

Both styles are well formed, correct, and appropriate. Which one is more appropriate depends largely upon your company's style guidelines. Modern IDEs will facilitate the use of both styles through the use of live syntax linting that explicitly highlight areas that might have otherwise become a source of confusion.

For example, the following expression is highlighted by Netbeans:

if($a = someFunction())
if($a = someFunction())

on the grounds of "accidental assignment".

enter image description here

To explicitly tell Netbeans that "yeah, I really meant to do that...", the expression can be wrapped in a set of parenthesis.

if(($a = someFunction()))
if(($a = someFunction()))

enter image description here

At the end of the day, it all boils down to company style guidelines and the availability of modern tools to facilitate the development process.

Both styles are well formed, correct, and appropriate. Which one is more appropriate depends largely upon your company's style guidelines. Modern IDEs will facilitate the use of both styles through the use of live syntax linting that explicitly highlight areas that might have otherwise become a source of confusion.

For example, the following expression is highlighted by Netbeans:

if($a = someFunction())

on the grounds of "accidental assignment".

enter image description here

To explicitly tell Netbeans that "yeah, I really meant to do that...", the expression can be wrapped in a set of parenthesis.

if(($a = someFunction()))

enter image description here

At the end of the day, it all boils down to company style guidelines and the availability of modern tools to facilitate the development process.

Both styles are well formed, correct, and appropriate. Which one is more appropriate depends largely upon your company's style guidelines. Modern IDEs will facilitate the use of both styles through the use of live syntax linting that explicitly highlight areas that might have otherwise become a source of confusion.

For example, the following expression is highlighted by Netbeans:

if($a = someFunction())

on the grounds of "accidental assignment".

enter image description here

To explicitly tell Netbeans that "yeah, I really meant to do that...", the expression can be wrapped in a set of parenthesis.

if(($a = someFunction()))

enter image description here

At the end of the day, it all boils down to company style guidelines and the availability of modern tools to facilitate the development process.

Source Link

Both styles are well formed, correct, and appropriate. Which one is more appropriate depends largely upon your company's style guidelines. Modern IDEs will facilitate the use of both styles through the use of live syntax linting that explicitly highlight areas that might have otherwise become a source of confusion.

For example, the following expression is highlighted by Netbeans:

if($a = someFunction())

on the grounds of "accidental assignment".

enter image description here

To explicitly tell Netbeans that "yeah, I really meant to do that...", the expression can be wrapped in a set of parenthesis.

if(($a = someFunction()))

enter image description here

At the end of the day, it all boils down to company style guidelines and the availability of modern tools to facilitate the development process.