10 Rules of otherwise - performance question
Morning -
Just curious if this really matters --
If you have 10 rules like the below example -which way is better to implement them or does it really matter??
Rule #1
If game.attribute = 1
Play sound 1
-otherwise-
Rule #2
If game.attribute =2
Play sound 2
-otherwise-
Rule #3
If game.attribute =3
Play sound 3
and so on to 10
** OR **
just list 10 separate rules
Rule #1
If game.attribute = 1
Play sound 1
Rule #2
If game.attribute =2
Play sound 2
Rule #3
If game.attribute =3
Play sound 3
and so on to 10
thx
Just curious if this really matters --
If you have 10 rules like the below example -which way is better to implement them or does it really matter??
Rule #1
If game.attribute = 1
Play sound 1
-otherwise-
Rule #2
If game.attribute =2
Play sound 2
-otherwise-
Rule #3
If game.attribute =3
Play sound 3
and so on to 10
** OR **
just list 10 separate rules
Rule #1
If game.attribute = 1
Play sound 1
Rule #2
If game.attribute =2
Play sound 2
Rule #3
If game.attribute =3
Play sound 3
and so on to 10
thx
Comments
the second one will needlessly read all the rules, even when a condition has been met.
(thats what you get for posting just when you wake up
I'm not smart enough to nest Otherwise statements too far without ripping my hair out. Well, what it left of it.
H
So if 1 is true it doens't check the 9 other If Statements...
If 1 is false then it checks if 2 is true... if that one is it doesn't need to check the rest, and so on.
So yes the first 1 is a better choice as long as you don't want 1 and 2 to be true at the same time...