Jump to content

if (confusin)


Drycodez

Recommended Posts

That's exactly the kind of place to use an else if. It makes program execution more efficient and also reminds you, the developer, that you only want to execute one code block, not several. That makes it easy to remember what you want to happen.

if (h == 1){   // execute this}else if (h == 2){   // execute that}

Not using an else might imply to you, the developer, that a set of conditions could exist where both code blocks could be executed. This way, it's absolutely clear that that will never happen.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...