View Single Post
  #11  
Old 12-30-2003, 10:33 PM
Thought Thought is offline
PipBoy Extraordinaire!
Thought's Avatar
Join Date: Nov 2001
Location: Long Beach, California.
Posts: 692
Thought is on a distinguished road
Quote:
Originally posted by HoudiniMan


Why do people do those "elseif"s in this situation?
I KNOW for a fact "if" by itself would work fine, i was just wondering if there's acutally a viable reason for doing this...
Optimization.
NPC Code:
// Both are being checked.
if (thing==A) {
}
if (thing==B) {
}

// If the first statement is false, check the second statement, else, skip the second statement.
if (thing==A) {
}
else if (thing==B) {
}



Think of it this way:

If thing is A, how could it ever be B? So why should you check it twice if thing is A?
__________________
Rick ([email protected])
#gscript on FreeNode (#gscript Guild, #gscript Information)
Graal User Statistics

I am now using my new account, Rick.
Reply With Quote