ID:266371
 
say if you had...

if(m==c) if(d==s)


now by doing this, does it read the first if statement and if it's false stop, or is this for if 1 is true, then if 2 is true?

also

if you had


if(owner==s.owner)
else
if(blah==blah)
else
if(blah==blah)

this is more efficient than doing

if(blah==blah)
if(blah==blah)
if(blah==blah)


right?

and

else
if(blah==blah)
if(blah==blah)

is not the same thing as doing
if(m==c) if(d==s)


correct?
Take a look at ||, and &&.
In response to Nadrew
Yeah like if you want something to meet 2 coniditions before calling true try like this.

This could be used in a shop to both check what the selection was and if they person has enough gold to cover it.

if(selection == "sword" && gold > 24)
gold -= 25
weapon = "sword"

This checks to make sure you have at least 25 gold for the sword and then makes your weapon var a sword.

LJR
Jon Snow wrote:
[snip]
if(m==c) if(d==s)
[snip]

If the first statement is false, it stops.

[snip]
if(owner==s.owner)
else
if(blah==blah)
else
if(blah==blah)

this is more efficient than doing

if(blah==blah)
if(blah==blah)
if(blah==blah)


right?
[snip]

If the statements depend on the ones before them, yes. More than just being more efficient, these two forms may be logically different. What if one statment checked if a value was not null and the next tried to use that value?

[snip]
else
if(blah==blah)
if(blah==blah)

is not the same thing as doing
if(m==c) if(d==s)


correct?
[snip]

The first form is only called if the check before the else failed. The second form is being called regardless of what happened before. They are different.