What are the differences between these three functions? Are either If functions "better" than switch?
I like Switch if I'm checking multiple things against the same variable. But if I'm checking a large number of things, I kind of prefer If else so that it "groups" the coding into tiers, so if I reviewing the trigger, I can find what I'm looking for easier. Is there any reason, be it function or aesthetics, to use one over the other two?
Well, when I saw switch, I thought it was meant to switch Boolean states, but it's basically If Then Else If, only all instances are compared to the initial statement, which calls a function or variable. So I suppose this relates to my Function call vs local variable thread, now that I think about it. I'm assuming that it "saves" the initial function so that it's not called it for every case, making it (possibly) superior to If then else.
I personally don't use Switch very often since it is limited to a single variable, as the If Then Else/If Then Else-If statements are more versatile. I imagine the Switch is used merely to simplify things, as Ahli634 mentioned.
What are the differences between these three functions? Are either If functions "better" than switch?
I like Switch if I'm checking multiple things against the same variable. But if I'm checking a large number of things, I kind of prefer If else so that it "groups" the coding into tiers, so if I reviewing the trigger, I can find what I'm looking for easier. Is there any reason, be it function or aesthetics, to use one over the other two?
I believe that the generated code is equal (as the galaxy language has no switch). So, it's just a different appearance in the editor.
@Ahli634: Go
Well, when I saw switch, I thought it was meant to switch Boolean states, but it's basically If Then Else If, only all instances are compared to the initial statement, which calls a function or variable. So I suppose this relates to my Function call vs local variable thread, now that I think about it. I'm assuming that it "saves" the initial function so that it's not called it for every case, making it (possibly) superior to If then else.
I personally don't use Switch very often since it is limited to a single variable, as the If Then Else/If Then Else-If statements are more versatile. I imagine the Switch is used merely to simplify things, as Ahli634 mentioned.
Custom Campaign Initiative | Mapster Community Project: Data Wizards
Starcraft II: Unsung Rebels, a custom campaign for Starcraft II
SC2Saver, a way to create saved games via trigger
Frustrated with the editor and would like answers in real time? Join the SC2Mapster Discord!