Jump to content

Proper syntax with IF statements that have no ELSE?


galvin

Recommended Posts

Just curious, what is proper programming in cases where you're just doing a simple IF statement where there really is no need for an ELSE.  Should you still write out the ELSE?

 

For example, which is proper...

if (x=1) {
//code here to do something
}

 

or

if (x=1) {
//code here to do something 
} else {
}

 

There would be nothing in the ELSE statement, so is it OK to just leave it out completely (i.e. version #1), or is it proper to still have it listed (i.e. version #2)?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.